Skip to content

Commit

Permalink
fix TOKEN KEY selection
Browse files Browse the repository at this point in the history
  • Loading branch information
MathisSenicourt committed May 14, 2024
1 parent b68ff33 commit aed8719
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const bodyParser = require('body-parser');
require('dotenv').config();

const { expressjwt: jwt } = require("express-jwt");
const privateAccesKey = process.env.PRIVATE_ACCES_KEY;
const privateAccesKey = process.env.ACCESS_TOKEN_KEY;

const sequelize = require('./service/database');
const cityRouteur = require("./routes/cityRoutes");
Expand Down
6 changes: 3 additions & 3 deletions service/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ require('dotenv').config();

// Fonction pour générer un access token
function generateAccessToken(mail) {
return jwt.sign({ mail }, process.env.PRIVATE_ACCES_KEY, { expiresIn: '2d', algorithm: 'HS256' });
return jwt.sign({ mail }, process.env.ACCESS_TOKEN_KEY, { expiresIn: '2d', algorithm: 'HS256' });
}

// Fonction pour générer un refresh token
function generateRefreshToken(mail) {
return jwt.sign({ mail }, process.env.PRIVATE_REFRESH_KEY, { expiresIn: '30d', algorithm: 'HS256' });
return jwt.sign({ mail }, process.env.REFRESH_TOKEN_KEY, { expiresIn: '30d', algorithm: 'HS256' });
}

// Fonction pour rafraîchir un token
Expand All @@ -22,7 +22,7 @@ async function getMailFromVerifiedRefreshToken(req, res) {
}

// Vérifier si le refresh token est valide
const decoded = jwt.verify(refreshToken, process.env.PRIVATE_REFRESH_KEY);
const decoded = jwt.verify(refreshToken, process.env.REFRESH_TOKEN_KEY);
console.log("decoded " + decoded);

return decoded.mail;
Expand Down

0 comments on commit aed8719

Please sign in to comment.