Skip to content

Commit

Permalink
perf: 优化会话过期500问题
Browse files Browse the repository at this point in the history
  • Loading branch information
O-Jiangweidong authored and BaiJiangJie committed Apr 23, 2024
1 parent 50cbb75 commit 95f29a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion apps/authentication/api/mfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def perform_create(self, serializer):
mfa_type = serializer.validated_data['type']

if not username:
user = self.get_user_from_session()
try:
user = self.get_user_from_session()
except errors.SessionEmptyError as e:
raise ValidationError({'error': e})
else:
user = self.get_user_from_db(username)

Expand Down
2 changes: 1 addition & 1 deletion apps/templates/_mfa_login_field.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@

function onError (responseText, responseJson, status) {
setTimeout(function () {
toastr.error(responseJson.detail);
toastr.error(responseJson.detail || responseJson.error);
});
};

Expand Down

0 comments on commit 95f29a5

Please sign in to comment.