Enable auth whoami command

This commit is contained in:
Juan Cruz Viotti 2014-12-12 10:25:32 -04:00
parent 40fc9fca4f
commit b30b41d4bb
4 changed files with 19 additions and 1 deletions

View File

@ -25,3 +25,13 @@ exports.signup = ->
signupUrl = resin.settings.get('urls.signup')
absUrl = url.resolve(resin.settings.get('remoteUrl'), signupUrl)
open(absUrl)
exports.whoami = ->
resin.auth.whoami (error, username) ->
resin.errors.handle(error) if error?
if not username?
error = new Error('Username not found')
resin.errors.handle(error)
resin.log.out(username)

View File

@ -71,6 +71,11 @@ cli.addCommand
description: 'signup to resin.io'
action: actions.auth.signup
cli.addCommand
command: 'whoami'
description: 'get current username'
action: actions.auth.whoami
# ---------- App Module ----------
cli.addResource
name: 'app'

View File

@ -120,7 +120,7 @@ exports.getToken = (callback) ->
#
# @todo Maybe we should post to /logout or something to invalidate the token on the server?
#
exports.logout = (callback) ->
exports.logout = (callback = _.noop) ->
async.parallel([
(callback) ->

View File

@ -249,6 +249,9 @@ describe 'Auth:', ->
expect(error).to.not.exist
done()
it 'should not throw an error if callback is not passed', ->
expect(auth.logout).to.not.throw(Error)
describe '#parseCredentials', ->
describe 'given colon separated credentials', ->