Skip to content

Fully autonomous AI Agents system capable of performing complex penetration testing tasks

fix(users): preserve email case on change to match login, OAuth and create

Sergey Kozyrenko14e0a0ae71d0
diff --git a/backend/pkg/server/services/users.go b/backend/pkg/server/services/users.go
index 7baac50e..bdf7c75e 100644
--- a/backend/pkg/server/services/users.go
+++ b/backend/pkg/server/services/users.go
@@ -4,7 +4,6 @@ import (
"errors"
"net/http"
"slices"
- "strings"
"pentagi/pkg/server/auth"
"pentagi/pkg/server/logger"
@@ -211,8 +210,6 @@ func (s *UserService) ChangeEmailCurrentUser(c *gin.Context) {
return
}
- form.Mail = strings.ToLower(strings.TrimSpace(form.Mail))
-
uid := c.GetUint64("uid")
scope := func(db *gorm.DB) *gorm.DB {
return db.Where("id = ?", uid)
diff --git a/backend/pkg/server/services/users_test.go b/backend/pkg/server/services/users_test.go
index db353c41..f265c731 100644
--- a/backend/pkg/server/services/users_test.go
+++ b/backend/pkg/server/services/users_test.go
@@ -394,14 +394,14 @@ func TestChangeEmailCurrentUser(t *testing.T) {
},
},
{
- name: "mixed-case email is stored lowercase",
+ name: "mixed-case email is stored as entered (consistent with login and OAuth)",
requestBody: `{"current_password": "SecurePass123!", "mail": "[email protected]"}`,
uid: 1,
expectedCode: http.StatusOK,
checkResult: func(t *testing.T, db *gorm.DB) {
var user models.User
require.NoError(t, db.Where("id = 1").First(&user).Error)
- assert.Equal(t, "[email protected]", user.Mail)
+ assert.Equal(t, "[email protected]", user.Mail)
},
},
{