Created the "verify" route in the auth.ts
This commit is contained in:
parent
ddeb5a5c7f
commit
30e02b9dd6
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user