mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-27 09:12:29 +00:00
18 lines
378 B
CoffeeScript
18 lines
378 B
CoffeeScript
_ = require('lodash')
|
|
resin = require('../resin')
|
|
messages = require('../messages/messages')
|
|
|
|
exports.failIfNotLoggedIn = (fn, onError) ->
|
|
return ->
|
|
args = arguments
|
|
resin.auth.isLoggedIn (isLoggedIn) ->
|
|
|
|
if not isLoggedIn
|
|
error = new Error(messages.errors.loginRequired)
|
|
if onError?
|
|
return onError(error)
|
|
else
|
|
throw error
|
|
|
|
fn.apply(null, args)
|