From c92787a0d519db28862ff4f5521c50f925839b52 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 20 Mar 2022 16:31:48 +0100 Subject: [PATCH] API - active user if not when adding admin rigths --- fittrackee/tests/users/test_users_utils.py | 9 +++++++++ fittrackee/users/utils/admin.py | 2 ++ 2 files changed, 11 insertions(+) diff --git a/fittrackee/tests/users/test_users_utils.py b/fittrackee/tests/users/test_users_utils.py index dd972ebf..5d0eeb6a 100644 --- a/fittrackee/tests/users/test_users_utils.py +++ b/fittrackee/tests/users/test_users_utils.py @@ -36,6 +36,15 @@ class TestSetAdminRights: assert user_1_admin.admin is True + def test_it_activates_account_if_user_is_inactive( + self, app: Flask, inactive_user: User + ) -> None: + set_admin_rights(inactive_user.username) + + assert inactive_user.admin is True + assert inactive_user.is_active is True + assert inactive_user.confirmation_token is None + class TestIsValidEmail: @pytest.mark.parametrize( diff --git a/fittrackee/users/utils/admin.py b/fittrackee/users/utils/admin.py index 0038ef5a..2e0a0cbd 100644 --- a/fittrackee/users/utils/admin.py +++ b/fittrackee/users/utils/admin.py @@ -9,4 +9,6 @@ def set_admin_rights(username: str) -> None: if not user: raise UserNotFoundException() user.admin = True + user.is_active = True + user.confirmation_token = None db.session.commit()