balena-cli/lib/actions/auth.coffee

27 lines
570 B
CoffeeScript
Raw Normal View History

2014-12-01 10:11:00 -04:00
url = require('url')
2014-11-18 11:37:29 -04:00
open = require('open')
async = require('async')
2014-11-26 13:02:22 -04:00
resin = require('../resin')
exports.login = (credentials) ->
async.waterfall [
(callback) ->
if credentials?
2014-11-26 13:02:22 -04:00
return resin.auth.parseCredentials(credentials, callback)
else
2014-11-26 13:26:01 -04:00
return resin.ui.widgets.login(callback)
(credentials, callback) ->
2014-11-26 13:02:22 -04:00
resin.auth.login(credentials, callback)
2014-11-26 12:38:02 -04:00
], resin.errors.handle
2014-11-18 11:37:29 -04:00
2014-11-27 10:06:11 -04:00
exports.logout = ->
2014-11-26 13:02:22 -04:00
resin.auth.logout()
2014-11-18 11:48:05 -04:00
2014-11-18 11:37:29 -04:00
exports.signup = ->
2014-12-01 10:11:00 -04:00
signupUrl = resin.config.urls.signup
absUrl = url.resolve(resin.config.remoteUrl, signupUrl)
open(absUrl)