Skip to content

Commit

Permalink
Merge pull request #208 from pubpub/kalilsn/evaluator-login-fix
Browse files Browse the repository at this point in the history
Fix login for users first invited as evaluators
  • Loading branch information
kalilsn authored Feb 1, 2024
2 parents 1575f61 + 157f720 commit 0d211c6
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions core/lib/auth/loginData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,28 @@ export const getLoginData = cache(async () => {
return undefined;
}
let user = await prisma.user.findUnique({
where: { supabaseId: supabaseUser.id },
where: { email: supabaseUser.email },
include: {
memberships: {
include: {
community: true
}
}
}
community: true,
},
},
},
});

if (user && !user.supabaseId) {
// They logged in via supabase, but the app db record doesn't have a supabaseId yet
await prisma.user.update({
where: {
email: supabaseUser.email,
},
data: {
supabaseId: supabaseUser.id,
},
});
}

if (!user) {
// They successfully logged in via supabase, but no corresponding record was found in the
// app database
Expand Down Expand Up @@ -67,9 +79,9 @@ export const getLoginData = cache(async () => {
include: {
memberships: {
include: {
community: true
}
}
community: true,
},
},
},
});
}
Expand Down

0 comments on commit 0d211c6

Please sign in to comment.