mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-20 17:33:18 +00:00
Enable auth whoami command
This commit is contained in:
parent
40fc9fca4f
commit
b30b41d4bb
@ -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)
|
||||
|
@ -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'
|
||||
|
@ -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) ->
|
||||
|
@ -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', ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user