Skip to content

Commit c7eb4f1

Browse files
committed
fix: Update Reset Payment OTP Secret logic
1 parent 3d36575 commit c7eb4f1

File tree

2 files changed

+9
-10
lines changed
  • payment_integration_utils/payment_integration_utils

2 files changed

+9
-10
lines changed

payment_integration_utils/payment_integration_utils/client_overrides/form/user.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ frappe.ui.form.on("User", {
55
refresh: function (frm) {
66
if (
77
!is_2fa_otp_app_enabled() ||
8-
!frappe.user.has_role(payment_integration_utils.PAYOUT_AUTHORIZER) ||
8+
!frappe.user.has_role(payment_integration_utils.PAYMENT_AUTHORIZER) ||
99
frappe.session.user != frm.doc.name
1010
) {
1111
return;
@@ -28,7 +28,7 @@ frappe.ui.form.on("User", {
2828

2929
function is_2fa_otp_app_enabled() {
3030
return (
31-
cint(frappe.boot.sysdefaults.enable_two_factor_auth) &&
32-
frappe.boot.sysdefaults.two_factor_method === payment_integration_utils.AUTH_METHODS.OTP_APP
31+
frappe.boot.sysdefaults.payment_authentication_method ===
32+
payment_integration_utils.AUTH_METHODS.OTP_APP
3333
);
3434
}

payment_integration_utils/payment_integration_utils/utils/auth.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def verify_otp(otp: str, auth_id: str) -> dict:
103103
return Authenticate2FA(otp, auth_id).verify()
104104

105105

106-
# TODO: How To Handle This? (Also need changes in JS)
107106
@frappe.whitelist()
108107
def reset_otp_secret(user: str):
109108
"""
@@ -117,12 +116,12 @@ def reset_otp_secret(user: str):
117116
if ROLE_PROFILE.PAYMENT_AUTHORIZER.value not in frappe.get_roles():
118117
frappe.throw(_("You do not have permission to reset OTP Secret."))
119118

120-
settings = frappe.get_cached_doc("System Settings")
121-
122-
if not settings.enable_two_factor_auth:
119+
if Utils2FA.get_authentication_method() != AUTH_METHOD.OTP_APP.value:
123120
frappe.throw(
124-
_("You have to enable Two Factor Auth from System Settings."),
125-
title=_("Enable Two Factor Auth"),
121+
msg=_(
122+
"OTP App is not enabled for Payment Authentication. Contact System Administrator."
123+
),
124+
title=_("OTP App Not Enabled"),
126125
)
127126

128127
otp_issuer = Utils2FA.get_otp_issuer()
@@ -134,7 +133,7 @@ def reset_otp_secret(user: str):
134133
email_args = {
135134
"recipients": user_email,
136135
"sender": None,
137-
"subject": _("Payment OTP Secret Reset - {0}").format(otp_issuer),
136+
"subject": _("Payment OTP Secret Reset for {0}").format(otp_issuer),
138137
"message": _(
139138
"<p>Your payment OTP secret on <strong>{0}</strong> used for authorizing <strong>Bank Payments</strong> has been reset! <br><br> If you did not perform this reset and did not request it, please contact your <strong>System Administrator</strong> immediately!!</p>"
140139
).format(otp_issuer),

0 commit comments

Comments
 (0)