Area restrita - Questionario
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import * as cookie from "cookie";
|
||||
import { Session } from "@contracts/constants";
|
||||
import { getSessionCookieOptions } from "./lib/cookies";
|
||||
import { createRouter, authedQuery } from "./middleware";
|
||||
|
||||
export const authRouter = createRouter({
|
||||
me: authedQuery.query((opts) => opts.ctx.user),
|
||||
logout: authedQuery.mutation(async ({ ctx }) => {
|
||||
const opts = getSessionCookieOptions(ctx.req.headers);
|
||||
ctx.resHeaders.append(
|
||||
"set-cookie",
|
||||
cookie.serialize(Session.cookieName, "", {
|
||||
httpOnly: opts.httpOnly,
|
||||
path: opts.path,
|
||||
sameSite: opts.sameSite?.toLowerCase() as "lax" | "none",
|
||||
secure: opts.secure,
|
||||
maxAge: 0,
|
||||
}),
|
||||
);
|
||||
return { success: true };
|
||||
}),
|
||||
});
|
||||
Reference in New Issue
Block a user