mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 05:02:37 +01:00
🐛 fix CORS
This commit is contained in:
parent
4a0d4ae909
commit
9b59296af5
@ -4,12 +4,13 @@ import { NextFunction, Request, Response } from "express";
|
||||
|
||||
export function CORS(req: Request, res: Response, next: NextFunction) {
|
||||
res.set("Access-Control-Allow-Origin", "*");
|
||||
// TODO: use securer CSP policy
|
||||
// TODO: use better CSP policy
|
||||
res.set(
|
||||
"Content-security-policy",
|
||||
"default-src * data: blob: filesystem: about: ws: wss: 'unsafe-inline' 'unsafe-eval'; script-src * data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src * data: blob: 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src * data: blob: ; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline';"
|
||||
);
|
||||
res.set("Access-Control-Allow-Headers", req.header("Access-Control-Request-Headers") || "*");
|
||||
res.set("Access-Control-Allow-Methods", req.header("Access-Control-Request-Methods") || "*");
|
||||
|
||||
next();
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ router.post(
|
||||
gift_code_sku_id, // ? what is this
|
||||
captcha_key
|
||||
} = req.body;
|
||||
console.log("register", req.body.email, req.body.username, req.headers["cf-connecting-ip"]);
|
||||
// TODO: automatically join invite
|
||||
// TODO: gift_code_sku_id?
|
||||
// TODO: check password strength
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Router, Request, Response } from "express";
|
||||
import { UserModel, toObject } from "@fosscord/server-util";
|
||||
import { UserModel, toObject, PublicUserProjection } from "@fosscord/server-util";
|
||||
import { HTTPError } from "lambert-server";
|
||||
import { getPublicUser } from "../../../util/User";
|
||||
import { UserModifySchema } from "../../../schema/User";
|
||||
@ -28,7 +28,7 @@ router.patch("/", check(UserModifySchema), async (req: Request, res: Response) =
|
||||
}
|
||||
}
|
||||
|
||||
const user = await UserModel.findOneAndUpdate({ id: req.user_id }, body).exec();
|
||||
const user = await UserModel.findOneAndUpdate({ id: req.user_id }, body, { projection: PublicUserProjection }).exec();
|
||||
// TODO: dispatch user update event
|
||||
|
||||
res.json(toObject(user));
|
||||
|
Loading…
Reference in New Issue
Block a user