[Update] 修改mfa

This commit is contained in:
ibuler
2019-11-18 16:30:26 +08:00
parent bfd8a9c66d
commit c9ee8edeaf
14 changed files with 92 additions and 56 deletions

View File

@@ -89,7 +89,9 @@ class AuthMixin:
def check_user_mfa_if_need(self, user):
if self.request.session.get('auth_mfa'):
return
if not user.otp_enabled or not user.otp_secret_key:
if not user.mfa_enabled:
return
if not user.otp_secret_key and user.mfa_is_otp():
return
raise errors.MFARequiredError()

View File

@@ -130,8 +130,8 @@ class UserLoginGuardView(mixins.AuthMixin, RedirectView):
auth_login(self.request, user)
self.send_auth_signal(success=True, user=user)
self.clear_auth_mark()
# 启用但是没有设置otp
if user.otp_enabled and not user.otp_secret_key:
# 启用但是没有设置otp, 排除radius
if user.mfa_enabled_but_not_set():
# 1,2,mfa_setting & F
return reverse('users:user-otp-enable-authentication')
url = redirect_user_first_login_or_index(