balena-cli/lib/actions/auth.coffee

28 lines
604 B
CoffeeScript
Raw Normal View History

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