Untitled
unknown
plain_text
2 years ago
532 B
9
Indexable
// CAMINHO DO ARQUIVO: SRC/HELPERS/authenticate.js
const jwt = require('jsonwebtoken');
const { User } = require('../models');
const authenticateUser = async (email, password) => {
const user = await User.findOne({
where: {
email,
},
});
if (!user || user.password !== password) return null;
const JWT_PASSWORD = process.env.JWT_SECRET || 'krankenwagen';
const token = jwt.sign({ id: user.id, email: user.email }, JWT_PASSWORD, { expiresIn: '4h' });
return token;
};
module.exports = authenticateUser;Editor is loading...
Leave a Comment