WIP: enable non-csrf routes from modules

This commit is contained in:
Shane Kilkelly 2016-11-11 13:48:29 +00:00
parent 8726a8fb4d
commit 2cf2199964
2 changed files with 11 additions and 4 deletions

View file

@ -18,6 +18,10 @@ module.exports = Modules =
applyRouter: (webRouter, apiRouter) ->
for module in @modules
module.router?.apply(webRouter, apiRouter)
applyNonCsrfRouter: (webRouter, apiRouter) ->
for module in @modules
module.nonCsrfRouter?.apply(webRouter, apiRouter)
viewIncludes: {}
loadViewIncludes: (app) ->
@ -58,4 +62,4 @@ module.exports = Modules =
return callback(error) if error?
return callback null, results
Modules.loadModules()
Modules.loadModules()

View file

@ -90,9 +90,6 @@ webRouter.use session
secure: Settings.secureCookie
store: sessionStore
key: Settings.cookieName
webRouter.use csrfProtection
webRouter.use translations.expressMiddlewear
webRouter.use translations.setLangBasedOnDomainMiddlewear
# passport
webRouter.use passport.initialize()
@ -113,6 +110,12 @@ Modules.hooks.fire 'passportSetup', passport, (err) ->
if err?
logger.err {err}, "error setting up passport in modules"
Modules.applyNonCsrfRouter(webRouter, apiRouter)
webRouter.use csrfProtection
webRouter.use translations.expressMiddlewear
webRouter.use translations.setLangBasedOnDomainMiddlewear
# Measure expiry from last request, not last login
webRouter.use (req, res, next) ->
req.session.touch()