2014-11-18 15:37:29 +00:00
|
|
|
open = require('open')
|
2014-11-18 16:15:40 +00:00
|
|
|
async = require('async')
|
2014-11-18 12:41:13 +00:00
|
|
|
auth = require('../auth/auth')
|
2014-11-18 16:37:01 +00:00
|
|
|
authHooks = require('../hooks/auth')
|
2014-11-18 16:15:40 +00:00
|
|
|
widgets = require('../widgets/widgets')
|
2014-11-18 15:37:29 +00:00
|
|
|
config = require('../config')
|
2014-11-18 12:41:13 +00:00
|
|
|
|
|
|
|
exports.login = (credentials) ->
|
2014-11-18 16:15:40 +00:00
|
|
|
async.waterfall [
|
|
|
|
|
|
|
|
(callback) ->
|
|
|
|
if credentials?
|
|
|
|
return auth.parseCredentials(credentials, callback)
|
|
|
|
else
|
|
|
|
return widgets.login(callback)
|
|
|
|
|
|
|
|
(credentials, callback) ->
|
|
|
|
auth.login(credentials, callback)
|
|
|
|
|
|
|
|
], (error) ->
|
2014-11-18 12:41:13 +00:00
|
|
|
throw error if error?
|
2014-11-18 15:37:29 +00:00
|
|
|
|
2014-11-18 16:37:01 +00:00
|
|
|
exports.logout = authHooks.failIfNotLoggedIn ->
|
2014-11-18 15:48:05 +00:00
|
|
|
auth.logout()
|
|
|
|
|
2014-11-18 15:37:29 +00:00
|
|
|
exports.signup = ->
|
|
|
|
open(config.urls.signup)
|