Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion models/user/email_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ func ActivateUserEmail(ctx context.Context, userID int64, email string, activate

// Activate/deactivate a user's primary email address and account
if addr.IsPrimary {
user, exist, err := db.Get[User](ctx, builder.Eq{"id": userID, "email": email})
user, exist, err := db.Get[User](ctx, builder.Eq{"id": userID, "email": strings.ToLower(email)})
if err != nil {
return err
} else if !exist {
Expand Down
1 change: 1 addition & 0 deletions models/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,7 @@ func createUser(ctx context.Context, u *User, meta *Meta, createdByAdmin bool, o

u.LowerName = strings.ToLower(u.Name)
u.AvatarEmail = u.Email
u.Email = strings.ToLower(u.Email)
if u.Rands, err = GetUserSalt(); err != nil {
return err
}
Expand Down
25 changes: 25 additions & 0 deletions tests/integration/signup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,28 @@ func TestSignupEmailActive(t *testing.T) {
user = unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "test-user-1"})
assert.True(t, user.IsActive)
}

func TestSignUpWithUppercaseEmail(t *testing.T) {
defer tests.PrepareTestEnv(t)()
defer test.MockVariableValue(&setting.Service.RegisterEmailConfirm, true)()

req := NewRequestWithValues(t, "POST", "/user/sign_up", map[string]string{
"user_name": "Upper-user-1",
"email": "[email protected]",
"password": "password1",
"retype": "password1",
})
MakeRequest(t, req, http.StatusOK)

user := unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "Upper-user-1"})
session := loginUserWithPassword(t, "Upper-user-1", "password1")
activationCode := user.GenerateEmailActivateCode(user.Email)
req = NewRequestWithValues(t, "POST", "/user/activate", map[string]string{
"code": activationCode,
"password": "password1",
})
resp := session.MakeRequest(t, req, http.StatusSeeOther)
assert.Equal(t, "/", test.RedirectURL(resp))
user = unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "Upper-user-1"})
assert.True(t, user.IsActive)
}
Loading