Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复已登录用户不能配置2FA问题 #1500

Merged
merged 2 commits into from
May 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/templates/2fa.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h4 style="font-weight: bold">启用两步验证</h4>
</div>
<div class="form-group" style="display: grid">
<label class="control-label" for="qrcode-img">1. 使用Google身份验证器扫码:</label>
<img id="qrcode-img" key="" src="">
<img id="qrcode-img" key="" src="" style="width: 100%;height: auto;">
</div>
<div class="form-group">
<label class="control-label" for="otpCode">2. 输入6位验证码完成验证:</label>
Expand Down
2 changes: 1 addition & 1 deletion common/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ <h4 class="modal-title" id="myModalLabel2">扫码绑定</h4>
<div class="modal-body">
<div class="form-group">
<label class="control-label" for="qrcode-img">1. 使用Google身份验证器扫码:</label>
<img id="qrcode-img" key="" src="">
<img id="qrcode-img" key="" src="" style="width: 100%;height: auto;">
<label class="control-label" for="otp">2. 输入6位验证码完成绑定:</label>
<input class="form-control ng-valid ng-dirty ng-touched" id="otp" name="otpCode" type="text"
oninput="value=value.replace(/[^\d]/g,'')" autocomplete="off" required>
Expand Down
11 changes: 6 additions & 5 deletions sql_api/api_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,12 @@ def post(self, request):
user = Users.objects.get(username=engineer)
request_user = request.session.get('user')

if request_user:
if request_user != engineer:
return Response({'status': 1, 'msg': '登录用户与校验用户不一致!'})
else:
return Response({'status': 1, 'msg': '需先校验用户密码!'})
if not request.user.is_authenticated:
if request_user:
if request_user != engineer:
return Response({'status': 1, 'msg': '登录用户与校验用户不一致!'})
else:
return Response({'status': 1, 'msg': '需先校验用户密码!'})

if auth_type == 'disabled':
# 关闭2fa
Expand Down