Signing Out from client side - not removing session from DB
I'm using the create-t3-turbo mono repo
When I use the server side sign in/out button I can see the session is correctly removed from the DB, yay!
When I try and create a client side button to signOut it doesn't remove the session from the db, sad 😦
I have this code
"use client";
import { api } from "~/trpc/react";
export function SignOutButton() {
const signOut = api.auth.signOut.useMutation();
return (
<button onClick={() => signOut.mutate()}>
sign out
</button>
);
}
I get a response back, signOut.status is 'success' but the session stays in the DB
What is different about calling the signOut function from the client that I don't understand?
Many thanks in advance to anyone who looks over this and understands
GitHub
GitHub - t3-oss/create-t3-turbo: Clean and simple starter repo usin...
Clean and simple starter repo using the T3 Stack along with Expo React Native - t3-oss/create-t3-turbo
1 Reply
I can see the authRouter signOut function here in pacakges/api/src/router/auth.ts
export const authRouter = {
getSession: publicProcedure.query(({ ctx }) => {
return ctx.session;
}),
getSecretMessage: protectedProcedure.query(() => {
return "you can see this secret message!";
}),
signOut: protectedProcedure.mutation(async (opts) => {
if (!opts.ctx.token) {
return { success: false };
}
await invalidateSessionToken(opts.ctx.token);
return { success: true };
}),
} satisfies TRPCRouterRecord;
but dont know why it acts differently