More refactoring

This commit is contained in:
calzoneman 2015-11-01 17:42:20 -08:00
parent c2726898e5
commit 6505aa2f5e
4 changed files with 177 additions and 129 deletions

View file

@ -0,0 +1,19 @@
const STATIC_RESOURCE = /\..+$/;
export default function initialize(app, session) {
app.use((req, res, next) => {
if (STATIC_RESOURCE.test(req.path)) {
return next();
} else if (!req.signedCookies || !req.signedCookies.auth) {
return nuext();
} else {
session.verifySession(req.signedCookies.auth, (err, account) => {
if (!err) {
req.user = res.user = account;
}
next();
});
}
});
}