diff --git a/rhodecode/apps/login/tests/test_2fa.py b/rhodecode/apps/login/tests/test_2fa.py --- a/rhodecode/apps/login/tests/test_2fa.py +++ b/rhodecode/apps/login/tests/test_2fa.py @@ -48,16 +48,16 @@ class Test2FA(object): user = user_util.create_user(password=self.password) user.has_enabled_2fa = True user.init_secret_2fa() - recovery_cod_to_check = user.init_2fa_recovery_codes()[0] + recovery_code_to_check = user.init_2fa_recovery_codes()[0] Session().add(user) Session().commit() self.app.post( route_path('login'), {'username': user.username, 'password': self.password}) - response = self.app.post(route_path('check_2fa'), {'totp': recovery_cod_to_check}) + response = self.app.post(route_path('check_2fa'), {'totp': recovery_code_to_check}) assert response.status_code == 302 - response = self.app.post(route_path('check_2fa'), {'totp': recovery_cod_to_check}) + response = self.app.post(route_path('check_2fa'), {'totp': recovery_code_to_check}) response.mustcontain('Code is invalid. Try again!') def test_2fa_state_when_forced_by_admin(self, user_util): diff --git a/rhodecode/apps/my_account/views/my_account.py b/rhodecode/apps/my_account/views/my_account.py --- a/rhodecode/apps/my_account/views/my_account.py +++ b/rhodecode/apps/my_account/views/my_account.py @@ -226,7 +226,7 @@ class MyAccountView(BaseAppView, DataGri c.active = '2fa' user_instance = c.auth_user.get_instance() - state = self.request.POST.get('2fa_status') == '1' + state = str2bool(self.request.POST.get('2fa_status')) user_instance.has_enabled_2fa = state user_instance.update_userdata(update_2fa=time.time()) Session().commit() diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -813,7 +813,7 @@ class User(Base, BaseModel): Checks if 2fa was forced for ALL users (including current one) """ from rhodecode.model.settings import SettingsModel - # So now we're supporting only auth_rhodecode_global_2f + # So now we're supporting only auth_rhodecode_global_2fa if value := SettingsModel().get_setting_by_name('auth_rhodecode_global_2fa'): return value.app_settings_value return False