mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Fix activation of primary email addresses (#16385)
* fix: primary email cannot be activated * Primary email should be activated together with user account when 'RegisterEmailConfirm' is enabled. * To fix the existing error state. When 'RegisterEmailConfirm' is enabled, the admin should have permission to modify the activations status of user email. And the user should be allowed to send activation to primary email. * Only judge whether email is primary from email_address table. * Improve logging and refactor isEmailActive Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
@@ -1429,16 +1429,22 @@ func handleAccountActivation(ctx *context.Context, user *models.User) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := models.ActivateUserEmail(user.ID, user.Email, true); err != nil {
|
||||
log.Error("Unable to activate email for user: %-v with email: %s: %v", user, user.Email, err)
|
||||
ctx.ServerError("ActivateUserEmail", err)
|
||||
return
|
||||
}
|
||||
|
||||
log.Trace("User activated: %s", user.Name)
|
||||
|
||||
if err := ctx.Session.Set("uid", user.ID); err != nil {
|
||||
log.Error(fmt.Sprintf("Error setting uid in session: %v", err))
|
||||
log.Error("Error setting uid in session[%s]: %v", ctx.Session.ID(), err)
|
||||
}
|
||||
if err := ctx.Session.Set("uname", user.Name); err != nil {
|
||||
log.Error(fmt.Sprintf("Error setting uname in session: %v", err))
|
||||
log.Error("Error setting uname in session[%s]: %v", ctx.Session.ID(), err)
|
||||
}
|
||||
if err := ctx.Session.Release(); err != nil {
|
||||
log.Error("Error storing session: %v", err)
|
||||
log.Error("Error storing session[%s]: %v", ctx.Session.ID(), err)
|
||||
}
|
||||
|
||||
ctx.Flash.Success(ctx.Tr("auth.account_activated"))
|
||||
|
Reference in New Issue
Block a user