Minor fix for checking successful otp login
This commit is contained in:
parent
4b84a1a572
commit
f34d52fb65
3 changed files with 12 additions and 6 deletions
|
|
@ -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:
|
||||
|
|
|
|||
2
frappe/public/js/frappe/qrious.min.js
vendored
2
frappe/public/js/frappe/qrious.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue