Prevent demo user from enabling 2FA

This commit is contained in:
Madeline 2022-07-20 21:35:02 +10:00
parent c07950570c
commit 88259246fb

View File

@ -17,7 +17,9 @@ export interface TotpEnableSchema {
router.post("/", route({ body: "TotpEnableSchema" }), async (req: Request, res: Response) => { router.post("/", route({ body: "TotpEnableSchema" }), async (req: Request, res: Response) => {
const body = req.body as TotpEnableSchema; const body = req.body as TotpEnableSchema;
const user = await User.findOneOrFail({ where: { id: req.user_id }, select: ["data"] }); const user = await User.findOneOrFail({ where: { id: req.user_id }, select: ["data", "email"] });
if (user.email == "demo@maddy.k.vu") throw new HTTPError("Demo user, sorry", 400);
// TODO: Are guests allowed to enable 2fa? // TODO: Are guests allowed to enable 2fa?
if (user.data.hash) { if (user.data.hash) {