mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-26 17:01:04 +00:00
17 lines
326 B
CoffeeScript
17 lines
326 B
CoffeeScript
_ = require('lodash')
|
|
resin = require('../resin')
|
|
|
|
exports.failIfNotLoggedIn = (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)
|