3 var passport = require('passport');
4 var rateLimiter = require('./rate-limiter');
5 var logoutDestroyTokens = require('./logout-destroy-tokens');
6 var userScopes = require('gitter-web-identity/lib/user-scopes');
8 function ensureLoggedIn(req, res, next) {
9 /* Bearer strategy must return a user. If the user is { _anonymous: true }, it should be null */
10 if (req.user && req.user._anonymous) {
14 if (req.user && userScopes.isMissingTokens(req.user)) {
15 return logoutDestroyTokens(req, res, next);
22 passport.authenticate('bearer', { session: false, failWithError: true }),