fix(security): IDOR verifyToken+verifySelf, resetTokenSecret, firstname/lastname add, JWT expiresIn 7d
This commit is contained in:
@@ -7,6 +7,7 @@ const nodemailer = require("nodemailer");
|
||||
const tables = require("../tables");
|
||||
|
||||
const secretKey = process.env.APP_SECRET;
|
||||
const resetTokenSecret = process.env.RESET_TOKEN_SECRET;
|
||||
const saltRounds = 10;
|
||||
|
||||
const passwordSchema = Joi.string()
|
||||
@@ -171,7 +172,7 @@ const login = async (req, res) => {
|
||||
return res.status(401).json({ message: "Mot de passe incorrect" });
|
||||
}
|
||||
|
||||
const token = jwt.sign({ user: user.id }, secretKey);
|
||||
const token = jwt.sign({ user: user.id }, secretKey, { expiresIn: "7d" });
|
||||
|
||||
return res.status(200).json({
|
||||
message: "Connexion réussie",
|
||||
@@ -309,7 +310,7 @@ const edit = async (req, res) => {
|
||||
|
||||
const add = async (req, res, next) => {
|
||||
try {
|
||||
const { nickname, mail, password, confirmPassword } =
|
||||
const { firstname, lastname, nickname, mail, password, confirmPassword } =
|
||||
req.body;
|
||||
|
||||
const existingUserByMail = await tables.users.getByMail(mail);
|
||||
@@ -353,7 +354,7 @@ const add = async (req, res, next) => {
|
||||
|
||||
const insertId = await tables.users.create(user);
|
||||
|
||||
const token = jwt.sign({ user: user.id }, secretKey);
|
||||
const token = jwt.sign({ user: user.id }, secretKey, { expiresIn: "7d" });
|
||||
|
||||
res.status(201).json({ insertId, token });
|
||||
return insertId;
|
||||
|
||||
Reference in New Issue
Block a user