Merge pull request #27084 from GursheenK/2FA-email-verification
fix: send 2FA OTP email synchronously
This commit is contained in:
commit
5a1d670f0b
2 changed files with 8 additions and 24 deletions
|
|
@ -329,7 +329,7 @@ var request_otp = function (r) {
|
|||
$('.login-content:visible').append(
|
||||
`<div id="twofactor_div">
|
||||
<form class="form-verify">
|
||||
<div class="page-card-head">
|
||||
<div class="page-card-head p-0">
|
||||
<span class="indicator blue" data-text="Verification">{{ _("Verification") | e }}</span>
|
||||
</div>
|
||||
<div id="otp_div"></div>
|
||||
|
|
|
|||
|
|
@ -344,30 +344,14 @@ def send_token_via_email(user, token, otp_secret, otp_issuer, subject=None, mess
|
|||
hotp = pyotp.HOTP(otp_secret)
|
||||
otp = hotp.at(int(token))
|
||||
template_args = {"otp": otp, "otp_issuer": otp_issuer}
|
||||
if not subject:
|
||||
subject = get_email_subject_for_2fa(template_args)
|
||||
if not message:
|
||||
message = get_email_body_for_2fa(template_args)
|
||||
|
||||
email_args = {
|
||||
"recipients": user_email,
|
||||
"sender": None,
|
||||
"subject": subject,
|
||||
"message": message,
|
||||
"header": [_("Verfication Code"), "blue"],
|
||||
"delayed": False,
|
||||
"retry": 3,
|
||||
}
|
||||
|
||||
enqueue(
|
||||
method=frappe.sendmail,
|
||||
queue="short",
|
||||
timeout=300,
|
||||
event=None,
|
||||
is_async=True,
|
||||
job_name=None,
|
||||
now=False,
|
||||
**email_args,
|
||||
frappe.sendmail(
|
||||
recipients=user_email,
|
||||
subject=subject or get_email_subject_for_2fa(template_args),
|
||||
message=message or get_email_body_for_2fa(template_args),
|
||||
header=[_("Verfication Code"), "blue"],
|
||||
delayed=False,
|
||||
retry=3,
|
||||
)
|
||||
return True
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue