1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-11-27 16:28:27 +02:00

prioritized user submitted OAuth2 createData.email

This commit is contained in:
Gani Georgiev
2025-02-03 12:57:15 +02:00
parent acd72101c6
commit 9856c59de0
3 changed files with 103 additions and 7 deletions

View File

@@ -232,7 +232,11 @@ func oauth2Submit(e *core.RecordAuthWithOAuth2RequestEvent, optExternalAuth *cor
payload = map[string]any{}
}
payload[core.FieldNameEmail] = e.OAuth2User.Email
// assign the OAuth2 user email only if the user hasn't submitted one
// (ignore empty/invalid values for consistency with the OAuth2->existing user update flow)
if v, _ := payload[core.FieldNameEmail].(string); v == "" {
payload[core.FieldNameEmail] = e.OAuth2User.Email
}
// map known fields (unless the field was explicitly submitted as part of CreateData)
if _, ok := payload[e.Collection.OAuth2.MappedFields.Id]; !ok && e.Collection.OAuth2.MappedFields.Id != "" {