mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
FIX - ajout whitelist admins
This commit is contained in:
parent
81b5c4a42d
commit
4c1db84d78
4 changed files with 7 additions and 0 deletions
|
|
@ -31,6 +31,7 @@ services:
|
|||
FRONTEND_PORT: 5173
|
||||
USE_PORTS: false
|
||||
AUTHENTICATED_ROOMS: false
|
||||
ADMINS: '["ets@ets.com", "admin@admin.com"]'
|
||||
volumes:
|
||||
- ./server/auth_config.json:/usr/src/app/serveur/config/auth_config.json
|
||||
depends_on:
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ services:
|
|||
FRONTEND_PORT: 5173
|
||||
USE_PORTS: false
|
||||
AUTHENTICATED_ROOMS: false
|
||||
ADMINS: '["ets@ets.com", "admin@admin.com"]'
|
||||
volumes:
|
||||
- /opt/EvalueTonSavoir/auth_config.json:/usr/src/app/serveur/auth_config.json
|
||||
depends_on:
|
||||
|
|
|
|||
|
|
@ -21,3 +21,4 @@ FRONTEND_PORT=5173
|
|||
USE_PORTS=false
|
||||
|
||||
AUTHENTICATED_ROOMS=false
|
||||
ADMINS='["ets@ets.com", "admin@admin.com"]'
|
||||
|
|
|
|||
|
|
@ -4,10 +4,14 @@ const AppError = require('./AppError.js');
|
|||
const { UNAUTHORIZED_NO_TOKEN_GIVEN, UNAUTHORIZED_INVALID_TOKEN } = require('../constants/errorCodes');
|
||||
|
||||
dotenv.config();
|
||||
const whitelist = process.env.ADMINS ? JSON.parse(process.env.ADMINS) : [];
|
||||
|
||||
class Token {
|
||||
|
||||
create(email, userId, roles) {
|
||||
if (whitelist.includes(email)) {
|
||||
roles.push("admin");
|
||||
}
|
||||
return jwt.sign({ email, userId, roles }, process.env.JWT_SECRET);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue