code: function(request, response, next){
  		if (!utils.Misc.isNullOrUndefined(request.user) || request.originalUrl == '/error' || request.originalUrl.indexOf('/error?') == 0) {
  			next();
  		}
  		else {
  			var success = encodeURIComponent(request.protocol + '://' + request.get('host') + request.originalUrl);
  			response.redirect('/login?success=' + success + '&no_query=true'); //we don't want it to add any query string
  		}
  	}
docs: checks for logged-in UI user