You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: preserve user metadata when email_confirm=true in Confirm function
## Problem
When creating a user with `email_confirm: true`, the `Confirm` function in `internal/models/user.go` overwrites the user's existing metadata instead of merging the `email_verified: true` flag with it.
## Root Cause
The current implementation calls `UpdateUserMetaData` with only `{"email_verified": true}`, which replaces the entire metadata object instead of merging with existing data.
## Solution
1. Reload the user's latest state from the database to get the most recent metadata
2. Merge the `email_verified: true` flag with existing metadata
3. Use the existing `UpdateUserMetaData` function to properly update without data loss
## Testing
- ✅ Created user with `email_confirm: true` and custom metadata
- ✅ Verified metadata is preserved and `email_verified: true` is merged
- ✅ Confirmed fix works through Kong API gateway
- ✅ Tested user creation, updates, and deletion operations
## Impact
Fixes data loss issue where user metadata was being overwritten during email confirmation, ensuring all custom user data is preserved.
Closes#2088
0 commit comments