Implemented ensureAuthenticated