Commit 38b19ad
authored
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 #20881 parent 079b242 commit 38b19ad
1 file changed
+18
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | | - | |
453 | | - | |
454 | | - | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
455 | 470 | | |
456 | 471 | | |
457 | 472 | | |
| |||
0 commit comments