Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
feat(client): add auth:whoami
Browse files Browse the repository at this point in the history
This adds a new command to the client which will display the current
user who is logged into the deis controller.
  • Loading branch information
Matthew Fisher committed Oct 16, 2014
1 parent f1b3834 commit 8881a7b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions client/deis.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ def auth(self, args):
auth:cancel remove the current account
auth:login authenticate against a controller
auth:logout clear the current user session
auth:whoami display the authenticated user
Use `deis help [command]` to learn more.
"""
Expand Down Expand Up @@ -803,6 +804,7 @@ def auth_login(self, args):
response = self._session.post(url, data=payload, allow_redirects=False)
if response.status_code == requests.codes.found: # @UndefinedVariable
self._settings['controller'] = controller
self._settings['username'] = username
self._settings.save()
self._logger.info("Logged in as {}".format(username))
return username
Expand All @@ -824,9 +826,23 @@ def auth_logout(self, args):
self._session.cookies.clear()
self._session.cookies.save()
self._settings['controller'] = None
self._settings['username'] = None
self._settings.save()
self._logger.info('Logged out')

def auth_whoami(self, args):
"""
Displays the currently logged in user.
Usage: deis auth:whoami
"""
user = self._settings.get('username')
if user:
self._logger.info(user)
else:
self._logger.info(
'Not logged in. Use `deis login` or `deis register` to get started.')

def builds(self, args):
"""
Valid commands for builds:
Expand Down Expand Up @@ -2130,6 +2146,7 @@ def shortcuts(self, args):
('sharing:list', 'perms:list'),
('sharing:add', 'perms:create'),
('sharing:remove', 'perms:delete'),
('whoami', 'auth:whoami'),
])


Expand Down

0 comments on commit 8881a7b

Please sign in to comment.