Use session role for invite page, handle stale user sessions gracefully
Some checks failed
Build and Push Docker Image / build (push) Failing after 2m31s

Switch invite page from DB query (user.me) to JWT session for role checks,
avoiding failures when user ID is stale. Return friendly error from user.me
instead of throwing on missing user.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt
2026-02-14 13:30:55 +01:00
parent 0afd4d97c6
commit 9ee767b6cd
2 changed files with 15 additions and 5 deletions

View File

@@ -19,7 +19,7 @@ export const userRouter = router({
* Get current user profile
*/
me: protectedProcedure.query(async ({ ctx }) => {
return ctx.prisma.user.findUniqueOrThrow({
const user = await ctx.prisma.user.findUnique({
where: { id: ctx.user.id },
select: {
id: true,
@@ -41,6 +41,15 @@ export const userRouter = router({
lastLoginAt: true,
},
})
if (!user) {
throw new TRPCError({
code: 'UNAUTHORIZED',
message: 'User session is stale. Please log out and log back in.',
})
}
return user
}),
/**