Skip to content

Commit

Permalink
Add acceptedRule info in auth route
Browse files Browse the repository at this point in the history
  • Loading branch information
MathieuSchl committed Sep 19, 2024
1 parent c3ee487 commit 9275315
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions back/functions/userAuthorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ async function getUserAuth(app, userId) {
console.log(resTestIfCorrelationExist[0]);
return;
}

if (resTestIfCorrelationExist[1].length === 0) {
const emptyRes = {};
for (const column of resDescGdRole[1]) {
Expand All @@ -71,6 +72,22 @@ async function getUserAuth(app, userId) {
return emptyRes;
}
const userAuth = resTestIfCorrelationExist[1].reduce(authReducer);
const resGetRulesValid = await app.executeQuery(
app.db,
`SELECT
CASE WHEN dt_ruleSignature IS NULL THEN FALSE ELSE DATE_FORMAT(DATE_ADD(dt_ruleSignature, INTERVAL 4 MONTH),'%Y') = DATE_FORMAT(DATE_ADD(NOW(), INTERVAL 4 MONTH),'%Y') END AS "acceptedRule"
FROM users AS u
WHERE u.i_id = ?`,
[userId]
);

if (resGetRulesValid[0] || resGetRulesValid[1].length !== 1) {
console.log(resGetRulesValid[0]);
return;
}

userAuth.acceptedRule = resGetRulesValid[1][0].acceptedRule;

return userAuth;
}

Expand Down

0 comments on commit 9275315

Please sign in to comment.