Use session role for invite page, handle stale user sessions gracefully
Some checks failed
Build and Push Docker Image / build (push) Failing after 2m31s
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:
@@ -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
|
||||
}),
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user