2014-12-01 14:11:00 +00:00
|
|
|
url = require('url')
|
2014-11-18 15:37:29 +00:00
|
|
|
open = require('open')
|
2014-11-18 16:15:40 +00:00
|
|
|
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')
|
2014-11-18 12:41:13 +00:00
|
|
|
|
|
|
|
exports.login = (credentials) ->
|
2014-11-18 16:15:40 +00:00
|
|
|
async.waterfall [
|
|
|
|
|
|
|
|
(callback) ->
|
|
|
|
if credentials?
|
2014-11-26 17:02:22 +00:00
|
|
|
return resin.auth.parseCredentials(credentials, callback)
|
2014-11-18 16:15:40 +00:00
|
|
|
else
|
2014-12-05 16:00:15 +00:00
|
|
|
return ui.widgets.login(callback)
|
2014-11-18 16:15:40 +00:00
|
|
|
|
|
|
|
(credentials, callback) ->
|
2014-11-26 17:02:22 +00:00
|
|
|
resin.auth.login(credentials, callback)
|
2014-11-18 16:15:40 +00:00
|
|
|
|
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)
|