balena-cli/lib/hooks/auth.coffee
2014-11-18 12:36:43 -04:00

11 lines
258 B
CoffeeScript

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)