Untitled
unknown
plain_text
2 years ago
512 B
7
Indexable
// autenticacao
const webToken = require('jsonwebtoken');
const { User } = require('../models');
const loginAuth = async (email, password) => {
const user = await User.findOne({ where: { email } });
if (!user || user.password !== password) return null;
const passwordWithoutHash = process.env.JWT_SECRET || 'raisfonogreis';
const token = webToken.sign(
{ id: user.id, email: user.email },
passwordWithoutHash,
{ expiresIn: '1d' },
);
return token;
};
module.exports = {
loginAuth,
};Editor is loading...
Leave a Comment