2014-10-31 19:19:16 +00:00
|
|
|
# TODO: Persist token in a secure manner
|
2014-11-07 18:51:54 +00:00
|
|
|
data = require('../data/data')
|
2014-10-31 19:19:16 +00:00
|
|
|
|
|
|
|
token = null
|
|
|
|
|
2014-11-07 18:51:54 +00:00
|
|
|
exports.saveToken = (newToken, callback) ->
|
2014-10-31 19:19:16 +00:00
|
|
|
token = newToken
|
2014-11-07 18:51:54 +00:00
|
|
|
return callback(null, token)
|
2014-10-31 19:19:16 +00:00
|
|
|
|
2014-11-07 18:51:54 +00:00
|
|
|
exports.hasToken = (callback) ->
|
|
|
|
return callback(token?)
|
2014-10-31 19:19:16 +00:00
|
|
|
|
2014-11-07 18:51:54 +00:00
|
|
|
exports.getToken = (callback) ->
|
|
|
|
return callback(null, token or undefined)
|
2014-10-31 19:19:16 +00:00
|
|
|
|
2014-11-07 18:51:54 +00:00
|
|
|
exports.clearToken = (callback) ->
|
2014-10-31 19:19:16 +00:00
|
|
|
token = null
|
2014-11-07 18:51:54 +00:00
|
|
|
return callback?(null)
|