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()