balena-cli/lib/hooks/auth.coffee
2014-11-19 09:14:40 -04:00

12 lines
272 B
CoffeeScript

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