personal_website/miscellaneous/checkAuthenticated.ts
2024-09-23 23:24:59 +02:00

15 lines
504 B
TypeScript

import { type NextFunction, type Request, type Response } from "express";
import userModel, { values } from 'models/userModel';
async function checkAuthenticated(req: Request, res: Response, next: NextFunction) {
const pass = req.body.pass;
const password = await userModel.getValue(values.pass);
if (pass && password) {
if (pass == password) {
return next();
}
}
return res.status(500).json({ message: 'Error when getting transactions.' });
}
export default checkAuthenticated;