2014-12-05 15:51:52 +00:00
|
|
|
resin = require('../resin')
|
2014-11-18 16:36:43 +00:00
|
|
|
|
2014-11-27 14:06:11 +00:00
|
|
|
exports.user = (fn, onError) ->
|
2014-11-18 16:36:43 +00:00
|
|
|
return ->
|
2014-11-19 13:14:40 +00:00
|
|
|
args = arguments
|
2014-12-05 15:51:52 +00:00
|
|
|
resin.auth.isLoggedIn (isLoggedIn) ->
|
2014-11-25 13:37:53 +00:00
|
|
|
|
2014-11-18 16:36:43 +00:00
|
|
|
if not isLoggedIn
|
2014-11-26 17:35:01 +00:00
|
|
|
error = new Error('You have to log in')
|
2014-11-26 13:19:02 +00:00
|
|
|
if onError?
|
|
|
|
return onError(error)
|
|
|
|
else
|
2014-12-12 21:20:29 +00:00
|
|
|
console.error(error.message)
|
|
|
|
process.exit(1)
|
2014-11-18 16:36:43 +00:00
|
|
|
|
2014-11-19 13:14:40 +00:00
|
|
|
fn.apply(null, args)
|