diff --git a/src/lib/util/api/index.ts b/src/lib/util/api/index.ts index 58ab377..b5c24e4 100644 --- a/src/lib/util/api/index.ts +++ b/src/lib/util/api/index.ts @@ -21,13 +21,22 @@ export async function useAuth( const decoded: IJwtData = jwt.verify(token, Buffer.from(PUBLIC_KEY), { algorithms: ["RS256"], }) as IJwtData; - const user = await userRepo.findOne({ + let user = await userRepo.findOne({ where: { apiKey: decoded.apiKey, }, loadEagerRelations: eager || false, relations: eager ? ["sentFriendRequests", "receivedFriendRequests"] : [], }); + if (!user) { + user = await userRepo.findOne({ + where: { + id: decoded.id, + }, + loadEagerRelations: eager || false, + relations: eager ? ["sentFriendRequests", "receivedFriendRequests"] : [], + }); + } return user; } const user = await userRepo.findOne({ diff --git a/src/routes/lobby/+server.ts b/src/routes/lobby/+server.ts index e14f286..ab9c55c 100644 --- a/src/routes/lobby/+server.ts +++ b/src/routes/lobby/+server.ts @@ -18,6 +18,7 @@ export async function GET({ request }) { export async function POST({ request, getClientAddress }) { // TODO: per-ip room limit const body: IRoom = await request.json(); + console.log(body, request.headers); /* description may contain "### END DESCRIPTION ###" on its own line. if it does, get all lines after that */ const parsedDescription = body.description?.split("### END DESCRIPTION ###"); const description = parsedDescription?.slice(1)?.join("### END DESCRIPTION ###") || "";