🐛 Fix user not found warning when merging guest user (#1752)

This commit is contained in:
Luke Vella 2025-06-03 18:29:42 +01:00 committed by GitHub
parent faf0d73972
commit 07e99b77ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -120,9 +120,9 @@ const {
} }
} }
const isNewUser = !user.role && profile; const isNewUserFromOAuth = !user.role && profile;
// Check for new user login with OAuth provider // Check for new user login with OAuth provider
if (isNewUser) { if (isNewUserFromOAuth) {
// If role isn't set than the user doesn't exist yet // If role isn't set than the user doesn't exist yet
// This can happen if logging in with an OAuth provider // This can happen if logging in with an OAuth provider
const instanceSettings = await getInstanceSettings(); const instanceSettings = await getInstanceSettings();
@ -132,8 +132,9 @@ const {
} }
} }
if (!isNewUser && user.id) { // If this is an existing registered user
// merge guest user into newly logged in user if (user.id && user.role && user.email) {
// merge guest user into existing user
const session = await auth(); const session = await auth();
if (session?.user && !session.user.email) { if (session?.user && !session.user.email) {
await mergeGuestsIntoUser(user.id, [session.user.id]); await mergeGuestsIntoUser(user.id, [session.user.id]);