ensureAuthenticated middleware; add topic funtions