balena-cli/lib/actions/auth.coffee
2014-12-05 12:00:15 -04:00

28 lines
604 B
CoffeeScript

url = require('url')
open = require('open')
async = require('async')
resin = require('../resin')
ui = require('../ui')
exports.login = (credentials) ->
async.waterfall [
(callback) ->
if credentials?
return resin.auth.parseCredentials(credentials, callback)
else
return ui.widgets.login(callback)
(credentials, callback) ->
resin.auth.login(credentials, callback)
], resin.errors.handle
exports.logout = ->
resin.auth.logout()
exports.signup = ->
signupUrl = resin.settings.get('urls.signup')
absUrl = url.resolve(resin.settings.get('remoteUrl'), signupUrl)
open(absUrl)