balena-cli/lib/cli/cli-permissions.coffee
2014-12-05 11:51:52 -04:00

16 lines
291 B
CoffeeScript

resin = require('../resin')
exports.user = (fn, onError) ->
return ->
args = arguments
resin.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)