verify email workflow working

This commit is contained in:
Milo Schwartz 2024-10-04 23:14:40 -04:00
parent f007e8e87f
commit a8f2ccb94b
23 changed files with 16363 additions and 15802 deletions

View file

@ -3,6 +3,7 @@ import { lucia } from "@server/auth";
import createHttpError from "http-errors";
import HttpCode from "@server/types/HttpCode";
import response from "@server/utils/response";
import logger from "@server/logger";
export async function logout(
req: Request,
@ -20,14 +21,26 @@ export async function logout(
);
}
await lucia.invalidateSession(sessionId);
res.setHeader("Set-Cookie", lucia.createBlankSessionCookie().serialize());
try {
await lucia.invalidateSession(sessionId);
res.setHeader(
"Set-Cookie",
lucia.createBlankSessionCookie().serialize(),
);
return response<null>(res, {
data: null,
success: true,
error: false,
message: "Logged out successfully",
status: HttpCode.OK,
});
return response<null>(res, {
data: null,
success: true,
error: false,
message: "Logged out successfully",
status: HttpCode.OK,
});
} catch (error) {
return next(
createHttpError(
HttpCode.INTERNAL_SERVER_ERROR,
"Failed to log out",
),
);
}
}