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

Commit

Permalink
Make webapp2_extras/appengine/auth/models.User.validate_token return …
Browse files Browse the repository at this point in the history
…UserToken or None.

Make the implementation of webapp2_extras/appengine/auth/models.User.validate_token match
the documentation and return the UserToken instead of Bool. Also correct the unit tests.

This fixes issue #102.
  • Loading branch information
karlwmacmillan committed Apr 11, 2016
1 parent 74a5abd commit 3913586
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tests/extras_appengine_auth_models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ def test_user_token(self):
auth_id = 'foo'

token = m.create_auth_token(auth_id)
self.assertTrue(m.validate_auth_token(auth_id, token))
self.assertTrue(m.validate_auth_token(auth_id, token) != None)
m.delete_auth_token(auth_id, token)
self.assertFalse(m.validate_auth_token(auth_id, token))
self.assertNone(m.validate_auth_token(auth_id, token))

token = m.create_signup_token(auth_id)
self.assertTrue(m.validate_signup_token(auth_id, token))
self.assertTrue(m.validate_signup_token(auth_id, token) != None)
m.delete_signup_token(auth_id, token)
self.assertFalse(m.validate_signup_token(auth_id, token))
self.assertNone(m.validate_signup_token(auth_id, token))


class TestUniqueModel(test_base.BaseTestCase):
Expand Down
2 changes: 1 addition & 1 deletion webapp2_extras/appengine/auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def validate_token(cls, user_id, subject, token):
A :class:`UserToken` or None if the token does not exist.
"""
return cls.token_model.get(user=user_id, subject=subject,
token=token) is not None
token=token)

@classmethod
def create_auth_token(cls, user_id):
Expand Down

0 comments on commit 3913586

Please sign in to comment.