feat: Ensure MFA email and phone are validated before enabling (#3143)

Added validation checks to ensure that a user's email and phone number are provided before enabling MFA email and phone respectively. This fixes the issue where MFA could be enabled without these values, causing inconsistencies.
This commit is contained in:
千石 2024-08-26 08:40:22 +08:00 committed by GitHub
parent f2a94f671a
commit 65563fa0cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -289,6 +289,16 @@ func (c *ApiController) UpdateUser() {
}
}
if user.MfaEmailEnabled && user.Email == "" {
c.ResponseError(c.T("user:MFA email is enabled but email is empty"))
return
}
if user.MfaPhoneEnabled && user.Phone == "" {
c.ResponseError(c.T("user:MFA phone is enabled but phone number is empty"))
return
}
if msg := object.CheckUpdateUser(oldUser, &user, c.GetAcceptLanguage()); msg != "" {
c.ResponseError(msg)
return