Skip to content
This repository has been archived by the owner on Feb 15, 2018. It is now read-only.

Commit

Permalink
Add back user auth
Browse files Browse the repository at this point in the history
  • Loading branch information
madninja committed Sep 26, 2016
1 parent 67b2979 commit 75b95ad
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions helium_commander/commands/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,16 @@ def list(client):
"""
user = User.singleton(client)
User.display(client, [user])


@cli.command()
@click.argument('email')
@click.argument('password')
@pass_client
def auth(client, email, password): # pragma: no cover
"""Authenticate a user.
Authenticates the given EMAIL and PASSWORD and displays the api key.
"""
user = User.authenticate(client, email, password)
click.echo(user.meta.api_token)
12 changes: 12 additions & 0 deletions helium_commander/user.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import unicode_literals
from helium import User
from helium import response_json


def display_map(cls, client):
Expand All @@ -21,4 +22,15 @@ def _email(self):
])
return dict


def authenticate(cls, client, email, password): # pragma: no cover
url = client._build_url('user', 'auth')
json = {
'email': email,
'password': password
}
json = response_json(client.post(url, json=json), 200, extract=None)
return cls._mk_one(client, json)

User.display_map = classmethod(display_map)
User.authenticate = classmethod(authenticate)

0 comments on commit 75b95ad

Please sign in to comment.