summary refs log tree commit diff
path: root/src/api/routes/users/@me/mfa/totp/disable.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/routes/users/@me/mfa/totp/disable.ts')
-rw-r--r--src/api/routes/users/@me/mfa/totp/disable.ts19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/api/routes/users/@me/mfa/totp/disable.ts b/src/api/routes/users/@me/mfa/totp/disable.ts
index 2fe9355c..6bc9a5c7 100644
--- a/src/api/routes/users/@me/mfa/totp/disable.ts
+++ b/src/api/routes/users/@me/mfa/totp/disable.ts
@@ -1,8 +1,8 @@
-import { Router, Request, Response } from "express";
 import { route } from "@fosscord/api";
-import { verifyToken } from 'node-2fa';
+import { BackupCode, generateToken, TotpDisableSchema, User } from "@fosscord/util";
+import { Request, Response, Router } from "express";
 import { HTTPError } from "lambert-server";
-import { User, generateToken, BackupCode, TotpDisableSchema } from "@fosscord/util";
+import { verifyToken } from "node-2fa";
 
 const router = Router();
 
@@ -14,28 +14,27 @@ router.post("/", route({ body: "TotpDisableSchema" }), async (req: Request, res:
 	const backup = await BackupCode.findOne({ where: { code: body.code } });
 	if (!backup) {
 		const ret = verifyToken(user.totp_secret!, body.code);
-		if (!ret || ret.delta != 0)
-			throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008);
+		if (!ret || ret.delta != 0) throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008);
 	}
 
 	await User.update(
 		{ id: req.user_id },
 		{
 			mfa_enabled: false,
-			totp_secret: "",
-		},
+			totp_secret: ""
+		}
 	);
 
 	await BackupCode.update(
 		{ user: { id: req.user_id } },
 		{
-			expired: true,
+			expired: true
 		}
 	);
 
 	return res.json({
-		token: await generateToken(user.id),
+		token: await generateToken(user.id)
 	});
 });
 
-export default router;
\ No newline at end of file
+export default router;