Revert "feat: don't send verification code if failed signin limit is reached …"

This reverts commit f2e3037bc5c1aa7e7394b2bd734c45ef06516ec4.
This commit is contained in:
hsluoyz 2025-03-01 12:57:11 +08:00 committed by GitHub
parent 41d9422687
commit a79a2e7e55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 12 deletions

View File

@ -258,7 +258,7 @@ func (c *ApiController) SendVerificationCode() {
return return
} }
sendResp = object.SendVerificationCodeToEmail(organization, user, provider, clientIp, vform.Dest, c.GetAcceptLanguage()) sendResp = object.SendVerificationCodeToEmail(organization, user, provider, clientIp, vform.Dest)
case object.VerifyTypePhone: case object.VerifyTypePhone:
if vform.Method == LoginVerification || vform.Method == ForgetVerification { if vform.Method == LoginVerification || vform.Method == ForgetVerification {
if user != nil && util.GetMaskedPhone(user.Phone) == vform.Dest { if user != nil && util.GetMaskedPhone(user.Phone) == vform.Dest {
@ -304,7 +304,7 @@ func (c *ApiController) SendVerificationCode() {
c.ResponseError(fmt.Sprintf(c.T("verification:Phone number is invalid in your region %s"), vform.CountryCode)) c.ResponseError(fmt.Sprintf(c.T("verification:Phone number is invalid in your region %s"), vform.CountryCode))
return return
} else { } else {
sendResp = object.SendVerificationCodeToPhone(organization, user, provider, clientIp, phone, c.GetAcceptLanguage()) sendResp = object.SendVerificationCodeToPhone(organization, user, provider, clientIp, phone)
} }
} }

View File

@ -60,7 +60,7 @@ type VerificationRecord struct {
IsUsed bool `xorm:"notnull" json:"isUsed"` IsUsed bool `xorm:"notnull" json:"isUsed"`
} }
func IsAllowSend(user *User, remoteAddr, recordType, lang string) error { func IsAllowSend(user *User, remoteAddr, recordType string) error {
var record VerificationRecord var record VerificationRecord
record.RemoteAddr = remoteAddr record.RemoteAddr = remoteAddr
record.Type = recordType record.Type = recordType
@ -78,15 +78,10 @@ func IsAllowSend(user *User, remoteAddr, recordType, lang string) error {
return errors.New("you can only send one code in 60s") return errors.New("you can only send one code in 60s")
} }
err = checkSigninErrorTimes(user, lang)
if err != nil {
return err
}
return nil return nil
} }
func SendVerificationCodeToEmail(organization *Organization, user *User, provider *Provider, remoteAddr string, dest string, lang string) error { func SendVerificationCodeToEmail(organization *Organization, user *User, provider *Provider, remoteAddr string, dest string) error {
sender := organization.DisplayName sender := organization.DisplayName
title := provider.Title title := provider.Title
@ -104,7 +99,7 @@ func SendVerificationCodeToEmail(organization *Organization, user *User, provide
} }
content = strings.Replace(content, "%{user.friendlyName}", userString, 1) content = strings.Replace(content, "%{user.friendlyName}", userString, 1)
err := IsAllowSend(user, remoteAddr, provider.Category, lang) err := IsAllowSend(user, remoteAddr, provider.Category)
if err != nil { if err != nil {
return err return err
} }
@ -122,8 +117,8 @@ func SendVerificationCodeToEmail(organization *Organization, user *User, provide
return nil return nil
} }
func SendVerificationCodeToPhone(organization *Organization, user *User, provider *Provider, remoteAddr string, dest string, lang string) error { func SendVerificationCodeToPhone(organization *Organization, user *User, provider *Provider, remoteAddr string, dest string) error {
err := IsAllowSend(user, remoteAddr, provider.Category, lang) err := IsAllowSend(user, remoteAddr, provider.Category)
if err != nil { if err != nil {
return err return err
} }