From 5156835e80a93b5dc4480d374d32d6fcbcfe1c70 Mon Sep 17 00:00:00 2001 From: Bartlomiej Mika Date: Fri, 5 Dec 2025 15:38:46 -0500 Subject: [PATCH] Fix: Update users_by_email with all fields The security_data field, which includes the WasEmailVerified flag, must be preserved during email updates. The update query now includes all fields in the users_by_email table. https://codeberg.org/mapleopentech/monorepo/issues/1#issuecomment-8725011 --- .../maplefile-backend/internal/repo/user/update.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cloud/maplefile-backend/internal/repo/user/update.go b/cloud/maplefile-backend/internal/repo/user/update.go index 20309a0..5a2ad7f 100644 --- a/cloud/maplefile-backend/internal/repo/user/update.go +++ b/cloud/maplefile-backend/internal/repo/user/update.go @@ -62,13 +62,17 @@ func (impl userStorerImpl) UpdateByID(ctx context.Context, user *dom_user.User) // Delete old email entry batch.Query(`DELETE FROM users_by_email WHERE email = ?`, existingUser.Email) - // Insert new email entry + // Insert new email entry with ALL fields including security_data + // IMPORTANT: security_data contains WasEmailVerified flag which must be preserved batch.Query(` INSERT INTO users_by_email ( - email, id, first_name, last_name, status, created_at - ) VALUES (?, ?, ?, ?, ?, ?)`, - user.Email, user.ID, user.FirstName, user.LastName, - user.Status, user.CreatedAt, + email, id, first_name, last_name, name, lexical_name, + role, status, timezone, created_at, modified_at, + profile_data, security_data, metadata + ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, + user.Email, user.ID, user.FirstName, user.LastName, user.Name, user.LexicalName, + user.Role, user.Status, user.Timezone, user.CreatedAt, user.ModifiedAt, + profileDataJSON, securityDataJSON, metadataJSON, ) } else { // Just update the existing email entry