Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Support for user auth().
  • Loading branch information
mkucharz committed Jun 1, 2016
commit 45df3749e5e7a6a5715b2e06ab6be6535fc6adbf
16 changes: 16 additions & 0 deletions syncano/models/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ class Meta:
'methods': ['post'],
'path': '/users/{id}/reset_key/',
},
'auth': {
'methods': ['post'],
'path': '/user/auth/',
},
'list': {
'methods': ['get'],
'path': '/users/',
Expand All @@ -133,6 +137,18 @@ def reset_key(self):
connection = self._get_connection()
return connection.request('POST', endpoint)

def auth(self):
properties = self.get_endpoint_data()
endpoint = self._meta.resolve_endpoint('auth', properties)
connection = self._get_connection()

data = {
'username': connection.username,
'password' : connection.password
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obsolete whitespace before :

}

return connection.request('POST', endpoint, data=data)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should set user key automatically after auth?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, but there is other place to do that - this only simply to test credentials. For that, I think that we should refactor a little bit user auth in connection.py.


def _user_groups_method(self, group_id=None, method='GET'):
properties = self.get_endpoint_data()
endpoint = self._meta.resolve_endpoint('groups', properties)
Expand Down