From 0a5e5de5441a4553fea518625b9f022f8ab542af Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 17 Dec 2025 12:25:58 +0000 Subject: [PATCH] fix: Handle NULL password field for imported contacts Change Password field from string to null.String in User model to properly handle contacts imported from external systems (e.g., Magento) that have NULL passwords in the database. Previously, fetching contacts with NULL passwords caused a SQL scan error: "sql: Scan error on column index 4, name \"password\": converting NULL to string is unsupported" --- internal/user/models/models.go | 2 +- internal/user/user.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/user/models/models.go b/internal/user/models/models.go index ffd44708..18dcb5b9 100644 --- a/internal/user/models/models.go +++ b/internal/user/models/models.go @@ -57,7 +57,7 @@ type User struct { PhoneNumber null.String `db:"phone_number" json:"phone_number"` AvatarURL null.String `db:"avatar_url" json:"avatar_url"` Enabled bool `db:"enabled" json:"enabled"` - Password string `db:"password" json:"-"` + Password null.String `db:"password" json:"-"` LastActiveAt null.Time `db:"last_active_at" json:"last_active_at"` LastLoginAt null.Time `db:"last_login_at" json:"last_login_at"` Roles pq.StringArray `db:"roles" json:"roles"` diff --git a/internal/user/user.go b/internal/user/user.go index 6babbe44..c68d8921 100644 --- a/internal/user/user.go +++ b/internal/user/user.go @@ -114,7 +114,7 @@ func (u *Manager) VerifyPassword(email string, password []byte) (models.User, er u.lo.Error("error fetching user from db", "error", err) return user, envelope.NewError(envelope.GeneralError, u.i18n.Ts("globals.messages.errorFetching", "name", "{globals.terms.user}"), nil) } - if err := u.verifyPassword(password, user.Password); err != nil { + if err := u.verifyPassword(password, user.Password.String); err != nil { return user, envelope.NewError(envelope.InputError, u.i18n.T("user.invalidEmailPassword"), nil) } return user, nil