diff --git a/backend/service-authentication/auth.js b/backend/service-authentication/auth.js index a5a5487..a0a184f 100644 --- a/backend/service-authentication/auth.js +++ b/backend/service-authentication/auth.js @@ -32,11 +32,11 @@ async function authenticate(req, res) { const userList = await queries.checkLoginQuery(login, password); if (userList !== undefined && userList[0] !== undefined && userList[0].idUtilisateur > 0){ - setSessionCookie (req, res, { userId: userList[0].idUtilisateur }); - // return userList[0].idUtilisateur; - return getUserId(getSession(req)); + console.log("check"); + setSessionCookie (req, res, { username: login}); + return userList[0].idUtilisateur; } else { - setSessionCookie (req, res, {userId: -1}); + setSessionCookie (req, res, {username: -1}); return -1; } diff --git a/backend/service-authentication/checkLogin.js b/backend/service-authentication/checkLogin.js index e8a1dce..3de2160 100644 --- a/backend/service-authentication/checkLogin.js +++ b/backend/service-authentication/checkLogin.js @@ -8,8 +8,11 @@ async function checkLogin (req,res) { return sendError(res, 'Vous n\'avez pas envoyé le champ password'); const result = await auth.authenticate(req, res); - if (result){ - return sendMessage(res, result); + if (result > 0){ + return sendMessage(res, { + id: result, + username: req.body.login + }); } else{ return sendError(res, 'Invalid username or password');