diff --git a/src/routes/v1/auth.ts b/src/routes/v1/auth.ts index 7f42015..16212f7 100644 --- a/src/routes/v1/auth.ts +++ b/src/routes/v1/auth.ts @@ -1,7 +1,7 @@ import { Request, Response, Router } from "express"; import { validateSchema } from "@utils/error"; -import { loginValidation, tokenValidation } from "./validations/auth"; -import { login, logout } from "../../controller/auth"; +import { loginValidation, tokenValidation, verificationValidation } from "./validations/auth"; +import { login, logout, verifySession } from "@controller/auth"; 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" }); }); -// app.post("/verify", (req: Request, res: Response) => { -// // TODO: Integrate TOTP Verification -// }); +app.post("/verify", async (req: Request, res: Response) => { + 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) => { if (validateSchema(res, tokenValidation, req.body)) return;