From 457c6098a49ea6c9bb3fa328807103175effcead Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Mon, 4 Nov 2024 16:17:24 +0800 Subject: [PATCH] feat: fix MFA empty CountryCode bug and show MFA error better in frontend --- controllers/auth.go | 1 + controllers/verification.go | 1 + web/src/auth/LoginPage.js | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/controllers/auth.go b/controllers/auth.go index 1e8b1939..1a349799 100644 --- a/controllers/auth.go +++ b/controllers/auth.go @@ -854,6 +854,7 @@ func (c *ApiController) Login() { } if authForm.Passcode != "" { + user.CountryCode = user.GetCountryCode(user.CountryCode) mfaUtil := object.GetMfaUtil(authForm.MfaType, user.GetPreferredMfaProps(false)) if mfaUtil == nil { c.ResponseError("Invalid multi-factor authentication type") diff --git a/controllers/verification.go b/controllers/verification.go index 0d9db92a..dd24a978 100644 --- a/controllers/verification.go +++ b/controllers/verification.go @@ -294,6 +294,7 @@ func (c *ApiController) SendVerificationCode() { } vform.CountryCode = mfaProps.CountryCode + vform.CountryCode = user.GetCountryCode(vform.CountryCode) } provider, err = application.GetSmsProvider(vform.Method, vform.CountryCode) diff --git a/web/src/auth/LoginPage.js b/web/src/auth/LoginPage.js index abbe6148..54ed7d68 100644 --- a/web/src/auth/LoginPage.js +++ b/web/src/auth/LoginPage.js @@ -444,8 +444,8 @@ class LoginPage extends React.Component { formValues={values} authParams={casParams} application={this.getApplicationObj()} - onFail={() => { - Setting.showMessage("error", i18next.t("mfa:Verification failed")); + onFail={(errorMessage) => { + Setting.showMessage("error", errorMessage); }} onSuccess={(res) => loginHandler(res)} />); @@ -513,8 +513,8 @@ class LoginPage extends React.Component { formValues={values} authParams={oAuthParams} application={this.getApplicationObj()} - onFail={() => { - Setting.showMessage("error", i18next.t("mfa:Verification failed")); + onFail={(errorMessage) => { + Setting.showMessage("error", errorMessage); }} onSuccess={(res) => loginHandler(res)} />);