balena-cli/lib/hooks/auth.coffee

12 lines
272 B
CoffeeScript
Raw Normal View History

2014-11-18 16:36:43 +00:00
auth = require('../auth/auth')
messages = require('../messages/messages')
exports.failIfNotLoggedIn = (fn) ->
return ->
2014-11-19 13:14:40 +00:00
args = arguments
2014-11-18 16:36:43 +00:00
auth.isLoggedIn (isLoggedIn) ->
if not isLoggedIn
throw new Error(messages.errors.loginRequired)
2014-11-19 13:14:40 +00:00
fn.apply(null, args)