浏览代码

Minor fix for checking successful otp login

version-14
crossxcell99 8 年前
父节点
当前提交
f34d52fb65
共有 3 个文件被更改,包括 12 次插入6 次删除
  1. +10
    -4
      frappe/auth.py
  2. +1
    -1
      frappe/public/js/frappe/qrious.min.js
  3. +1
    -1
      frappe/templates/includes/login/login.js

+ 10
- 4
frappe/auth.py 查看文件

@@ -154,16 +154,20 @@ class LoginManager:
'prompt': status and 'Enter verification code sent to {}'.format(usr_phone[:4] + '******' + usr_phone[-3:]),
'method': 'SMS'}
elif verification_method == 'OTP App':
totp_uri = False

totp_uri = pyotp.TOTP(otp_secret).provisioning_uri(self.user, issuer_name="Estate Manager")

if frappe.db.get_default(self.user + '_otplogin'):
totp_uri = pyotp.TOTP(otp_secret).provisioning_uri(self.user, issuer_name="Estate Manager")
otp_setup_completed = True
else:
otp_setup_completed = False

verification_obj = {'token_delivery': True,
'prompt': False,
'totp_uri': totp_uri,
'method': 'OTP App',
'qrcode':get_qr_svg_code(totp_uri)}
'qrcode': get_qr_svg_code(totp_uri),
'otp_setup_completed': otp_setup_completed}
elif verification_method == 'Email':
status = self.send_token_via_email(token=token,otpsecret=otp_secret)
verification_obj = {'token_delivery': status,
@@ -185,7 +189,8 @@ class LoginManager:
'token_delivery': True,
'prompt': False,
'totp_uri': totp_uri,
'qrcode':get_qr_svg_code(totp_uri)
'qrcode':get_qr_svg_code(totp_uri),
'otp_setup_completed': False,
#'restrict_method': int(restrict_method) and (fixed_method[0].default_method or 'OTP App')
}

@@ -261,6 +266,7 @@ class LoginManager:
# show qr code only once
if not frappe.db.get_default(self.user + '_otpsecret'):
frappe.db.set_default(self.user + '_otpsecret', otp_secret)
if not frappe.db.get_default(self.user + '_otplogin'):
frappe.db.set_default(self.user + '_otplogin', 1)
return True
else:


+ 1
- 1
frappe/public/js/frappe/qrious.min.js
文件差异内容过多而无法显示
查看文件


+ 1
- 1
frappe/templates/includes/login/login.js 查看文件

@@ -347,7 +347,7 @@ login.login_handlers = (function() {
} else {
if (data.verification.method == 'OTP App'){
console.log(data.verification.totp_uri)
continue_otp(setup_completed = !data.verification.totp_uri);
continue_otp(setup_completed = data.verification.otp_setup_completed);
} else if (data.verification.method == 'SMS'){
continue_sms(setup_completed=true, method_prompt=data.verification.prompt);
console.log('SMS');


正在加载...
取消
保存