Implementation of the new_password endpoint.

Found a way to create the token that does not need to persist it to the database.
This requires proper error messages, written by people who speak menglis good.
This commit is contained in:
Rebecca Law
2016-01-07 17:13:49 +00:00
parent 8057a138a8
commit a860f713d2
17 changed files with 87 additions and 156 deletions

View File

@@ -1,12 +0,0 @@
import uuid
from app.main.dao import password_reset_token_dao
from tests.app.main import create_test_user
def test_should_insert_and_return_token(notifications_admin, notifications_admin_db, notify_db_session):
user = create_test_user('active')
token_id = str(uuid.uuid4())
password_reset_token_dao.insert(token=token_id, user_id=user.id)
saved_token = password_reset_token_dao.get_token(token_id)
assert saved_token.token == token_id

View File

@@ -176,7 +176,7 @@ def test_should_update_password(notifications_admin, notifications_admin_db, not
saved = users_dao.get_user_by_id(user.id)
assert check_hash('somepassword', saved.password)
assert saved.password_changed_at is None
users_dao.update_password(saved.id, 'newpassword')
users_dao.update_password(saved.email_address, 'newpassword')
updated = users_dao.get_user_by_id(user.id)
assert check_hash('newpassword', updated.password)
assert updated.password_changed_at < datetime.now()