balena-cli/lib/resin/cli/cli-permissions.coffee
2014-11-27 10:06:11 -04:00

16 lines
288 B
CoffeeScript

auth = require('../auth/auth')
exports.user = (fn, onError) ->
return ->
args = arguments
auth.isLoggedIn (isLoggedIn) ->
if not isLoggedIn
error = new Error('You have to log in')
if onError?
return onError(error)
else
throw error
fn.apply(null, args)