artsy-passport
Version:
Wires up the common auth handlers for Artsy's [Ezel](ezeljs.com)-based apps using [passport](http://passportjs.org/).
32 lines (26 loc) • 1.07 kB
JavaScript
// Generated by CoffeeScript 1.11.1
(function() {
var _, _s, opts;
_ = require('underscore');
_s = require('underscore.string');
opts = require('../options');
module.exports = function(req, res, next) {
var ref, ref1, ref2, ref3;
if (req.user) {
res.locals.user = req.user;
if ((ref = res.locals.sd) != null) {
ref.CURRENT_USER = req.user.toJSON();
}
}
if ((ref1 = res.locals.sd) != null) {
ref1.CSRF_TOKEN = res.locals.csrfToken = typeof req.csrfToken === "function" ? req.csrfToken() : void 0;
}
if ((ref2 = res.locals.sd) != null) {
ref2.ERROR = res.locals.error = _s.escapeHTML(req.query.error);
}
if ((ref3 = res.locals.sd) != null) {
ref3.AP = res.locals.ap = _.pick(opts, 'linkedinPath', 'linkedinCallbackPath', 'facebookPath', 'facebookCallbackPath', 'twitterPath', 'twitterCallbackPath', 'twitterLastStepPath', 'twitterSignupTempEmail', 'loginPagePath', 'signupPagePath', 'settingsPagePath', 'afterSignupPagePath', 'logoutPath');
}
return next();
};
}).call(this);