Implement authHooks module

This commit is contained in:
Juan Cruz Viotti 2014-11-18 12:36:43 -04:00
parent a0c743d771
commit 8bdd3b697a

10
lib/hooks/auth.coffee Normal file
View File

@ -0,0 +1,10 @@
auth = require('../auth/auth')
messages = require('../messages/messages')
exports.failIfNotLoggedIn = (fn) ->
return ->
auth.isLoggedIn (isLoggedIn) ->
if not isLoggedIn
throw new Error(messages.errors.loginRequired)
fn.apply(null, arguments)