mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
feat: fix issue that user email is still unverified after signup (#3685)
This commit is contained in:
parent
08f7a05e61
commit
e55cd94298
@ -139,6 +139,8 @@ func (c *ApiController) Signup() {
|
|||||||
invitationName = invitation.Name
|
invitationName = invitation.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
userEmailVerified := false
|
||||||
|
|
||||||
if application.IsSignupItemVisible("Email") && application.GetSignupItemRule("Email") != "No verification" && authForm.Email != "" {
|
if application.IsSignupItemVisible("Email") && application.GetSignupItemRule("Email") != "No verification" && authForm.Email != "" {
|
||||||
var checkResult *object.VerifyResult
|
var checkResult *object.VerifyResult
|
||||||
checkResult, err = object.CheckVerificationCode(authForm.Email, authForm.EmailCode, c.GetAcceptLanguage())
|
checkResult, err = object.CheckVerificationCode(authForm.Email, authForm.EmailCode, c.GetAcceptLanguage())
|
||||||
@ -150,6 +152,8 @@ func (c *ApiController) Signup() {
|
|||||||
c.ResponseError(checkResult.Msg)
|
c.ResponseError(checkResult.Msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
userEmailVerified = true
|
||||||
}
|
}
|
||||||
|
|
||||||
var checkPhone string
|
var checkPhone string
|
||||||
@ -228,6 +232,7 @@ func (c *ApiController) Signup() {
|
|||||||
Karma: 0,
|
Karma: 0,
|
||||||
Invitation: invitationName,
|
Invitation: invitationName,
|
||||||
InvitationCode: authForm.InvitationCode,
|
InvitationCode: authForm.InvitationCode,
|
||||||
|
EmailVerified: userEmailVerified,
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(organization.Tags) > 0 {
|
if len(organization.Tags) > 0 {
|
||||||
|
@ -483,6 +483,14 @@ func (c *ApiController) Login() {
|
|||||||
verificationType = "sms"
|
verificationType = "sms"
|
||||||
} else {
|
} else {
|
||||||
verificationType = "email"
|
verificationType = "email"
|
||||||
|
if !user.EmailVerified {
|
||||||
|
user.EmailVerified = true
|
||||||
|
_, err = object.UpdateUser(user.GetId(), user, []string{"email_verified"}, false)
|
||||||
|
if err != nil {
|
||||||
|
c.ResponseError(err.Error(), nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var application *object.Application
|
var application *object.Application
|
||||||
|
@ -436,7 +436,8 @@ func (c *ApiController) ResetEmailOrPhone() {
|
|||||||
switch destType {
|
switch destType {
|
||||||
case object.VerifyTypeEmail:
|
case object.VerifyTypeEmail:
|
||||||
user.Email = dest
|
user.Email = dest
|
||||||
_, err = object.SetUserField(user, "email", user.Email)
|
user.EmailVerified = true
|
||||||
|
_, err = object.UpdateUser(user.GetId(), user, []string{"email", "email_verified"}, false)
|
||||||
case object.VerifyTypePhone:
|
case object.VerifyTypePhone:
|
||||||
user.Phone = dest
|
user.Phone = dest
|
||||||
_, err = object.SetUserField(user, "phone", user.Phone)
|
_, err = object.SetUserField(user, "phone", user.Phone)
|
||||||
|
@ -60,7 +60,8 @@ func (mfa *SmsMfa) Enable(user *User) error {
|
|||||||
columns = append(columns, "mfa_phone_enabled", "phone", "country_code")
|
columns = append(columns, "mfa_phone_enabled", "phone", "country_code")
|
||||||
} else if mfa.MfaType == EmailType {
|
} else if mfa.MfaType == EmailType {
|
||||||
user.MfaEmailEnabled = true
|
user.MfaEmailEnabled = true
|
||||||
columns = append(columns, "mfa_email_enabled", "email")
|
user.EmailVerified = true
|
||||||
|
columns = append(columns, "mfa_email_enabled", "email", "email_verified")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := UpdateUser(user.GetId(), user, columns, false)
|
_, err := UpdateUser(user.GetId(), user, columns, false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user