[Update] 修改MFA

This commit is contained in:
ibuler
2019-11-18 18:12:03 +08:00
parent c9ee8edeaf
commit bb1349e962
11 changed files with 29 additions and 38 deletions

View File

@@ -172,8 +172,8 @@ class UserResetOTPApi(UserQuerysetMixin, generics.RetrieveAPIView):
if user == request.user:
msg = _("Could not reset self otp, use profile reset instead")
return Response({"error": msg}, status=401)
if user.mfa_enabled and user.otp_secret_key:
user.otp_secret_key = ''
if user.mfa_enabled:
user.reset_mfa()
user.save()
logout(request)
return Response({"msg": "success"})