Fix: Add testing

This commit is contained in:
Aron Malcher 2024-03-01 20:50:11 +01:00
parent d022d9fcf6
commit ed6195e1e2
Signed by: aronmal
GPG key ID: 816B7707426FC612
22 changed files with 338 additions and 87 deletions

View file

@ -11,12 +11,11 @@ import { discord, lucia } from "~/lib/auth";
import { paths } from "~/types/discord";
export async function GET(event: APIEvent): Promise<Response> {
const code = new URL(event.request.url).searchParams.get("code");
const state = new URL(event.request.url).searchParams.get("state");
const error = new URL(event.request.url).searchParams.get("error");
const error_description = new URL(event.request.url).searchParams.get(
"error_description",
);
const url = new URL(event.request.url);
const code = url.searchParams.get("code");
const state = url.searchParams.get("state");
const error = url.searchParams.get("error");
const error_description = url.searchParams.get("error_description");
if (error)
switch (error) {
case "access_denied":
@ -61,7 +60,6 @@ export async function GET(event: APIEvent): Promise<Response> {
{ sessionId: createId() },
);
const sessionCookie = lucia.createSessionCookie(session.id);
console.log(sessionCookie);
setCookie(
sessionCookie.name,
sessionCookie.value,
@ -100,7 +98,6 @@ export async function GET(event: APIEvent): Promise<Response> {
})
.returning()
.execute();
console.log(createId(), createId(), { warst: createId() });
const session = await lucia.createSession(
userId,
{},

View file

@ -4,6 +4,9 @@ import httpStatus from "http-status";
import { setCookie } from "vinxi/http";
import { discord } from "~/lib/auth";
if (typeof import.meta.env.PROD === "undefined")
throw new Error("No env PROD found!");
export async function GET(event: APIEvent) {
const state = generateState();
const url = await discord.createAuthorizationURL(state, {