dev #2
2 changed files with 11 additions and 1 deletions
|
@ -21,13 +21,22 @@ export async function useAuth(
|
||||||
const decoded: IJwtData = jwt.verify(token, Buffer.from(PUBLIC_KEY), {
|
const decoded: IJwtData = jwt.verify(token, Buffer.from(PUBLIC_KEY), {
|
||||||
algorithms: ["RS256"],
|
algorithms: ["RS256"],
|
||||||
}) as IJwtData;
|
}) as IJwtData;
|
||||||
const user = await userRepo.findOne({
|
let user = await userRepo.findOne({
|
||||||
where: {
|
where: {
|
||||||
apiKey: decoded.apiKey,
|
apiKey: decoded.apiKey,
|
||||||
},
|
},
|
||||||
loadEagerRelations: eager || false,
|
loadEagerRelations: eager || false,
|
||||||
relations: eager ? ["sentFriendRequests", "receivedFriendRequests"] : [],
|
relations: eager ? ["sentFriendRequests", "receivedFriendRequests"] : [],
|
||||||
});
|
});
|
||||||
|
if (!user) {
|
||||||
|
user = await userRepo.findOne({
|
||||||
|
where: {
|
||||||
|
id: decoded.id,
|
||||||
|
},
|
||||||
|
loadEagerRelations: eager || false,
|
||||||
|
relations: eager ? ["sentFriendRequests", "receivedFriendRequests"] : [],
|
||||||
|
});
|
||||||
|
}
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
const user = await userRepo.findOne({
|
const user = await userRepo.findOne({
|
||||||
|
|
|
@ -18,6 +18,7 @@ export async function GET({ request }) {
|
||||||
export async function POST({ request, getClientAddress }) {
|
export async function POST({ request, getClientAddress }) {
|
||||||
// TODO: per-ip room limit
|
// TODO: per-ip room limit
|
||||||
const body: IRoom = await request.json();
|
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 */
|
/* 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 parsedDescription = body.description?.split("### END DESCRIPTION ###");
|
||||||
const description = parsedDescription?.slice(1)?.join("### END DESCRIPTION ###") || "";
|
const description = parsedDescription?.slice(1)?.join("### END DESCRIPTION ###") || "";
|
||||||
|
|
Loading…
Reference in a new issue