Created the "verify" route in the auth.ts

This commit is contained in:
Mathias Wagner 2023-01-21 14:02:20 +01:00
parent ddeb5a5c7f
commit 30e02b9dd6
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -1,7 +1,7 @@
import { Request, Response, Router } from "express"; import { Request, Response, Router } from "express";
import { validateSchema } from "@utils/error"; import { validateSchema } from "@utils/error";
import { loginValidation, tokenValidation } from "./validations/auth"; import { loginValidation, tokenValidation, verificationValidation } from "./validations/auth";
import { login, logout } from "../../controller/auth"; import { login, logout, verifySession } from "@controller/auth";
const app: Router = Router(); const app: Router = Router();
@ -14,9 +14,14 @@ app.post("/login", async (req: Request, res: Response) => {
res.header("Authorization", session?.token).json({ ...session, message: "Your session got successfully created" }); res.header("Authorization", session?.token).json({ ...session, message: "Your session got successfully created" });
}); });
// app.post("/verify", (req: Request, res: Response) => { app.post("/verify", async (req: Request, res: Response) => {
// // TODO: Integrate TOTP Verification if (validateSchema(res, verificationValidation, req.body)) return;
// });
const session = await verifySession(req.body);
if (session) return res.json(session);
res.json({ message: "Your session got verified" });
});
app.post("/logout", async (req: Request, res: Response) => { app.post("/logout", async (req: Request, res: Response) => {
if (validateSchema(res, tokenValidation, req.body)) return; if (validateSchema(res, tokenValidation, req.body)) return;