mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-26 17:01:04 +00:00
15 lines
348 B
CoffeeScript
15 lines
348 B
CoffeeScript
_ = require('lodash')
|
|
auth = require('../auth/auth')
|
|
messages = require('../messages/messages')
|
|
|
|
exports.failIfNotLoggedIn = (fn, onError) ->
|
|
return ->
|
|
args = arguments
|
|
auth.isLoggedIn (isLoggedIn) ->
|
|
|
|
if not isLoggedIn
|
|
error = new Error(messages.errors.loginRequired)
|
|
return onError?(error) or throw error
|
|
|
|
fn.apply(null, args)
|