Compare commits
10 Commits
6af45b3ee2
...
b7552e3d13
| Author | SHA1 | Date | |
|---|---|---|---|
| b7552e3d13 | |||
|
|
912b12c627 | ||
|
|
c9fb03b499 | ||
|
|
464ff4d8b4 | ||
| 5275c61483 | |||
| 4a68b5a724 | |||
| 5b0d68d66f | |||
| 756f928ced | |||
| 48aa16962c | |||
| bdab795506 |
5
.env
5
.env
@@ -2,4 +2,7 @@ DATABASE = mia_dev
|
|||||||
DATABASE_HOST = db.thecoredev.fr
|
DATABASE_HOST = db.thecoredev.fr
|
||||||
DATABASE_PORT = 3306
|
DATABASE_PORT = 3306
|
||||||
DATABASE_USER = mia
|
DATABASE_USER = mia
|
||||||
DATABASE_PASSWORD = CalomOk0t-ISvpw-
|
DATABASE_PASSWORD = CalomOk0t-ISvpw-
|
||||||
|
|
||||||
|
MASTER_URL = 'https://slave.thecoredev.fr'
|
||||||
|
SLAVE_URL = 'https://slave.thecoredev.fr'
|
||||||
@@ -2,4 +2,7 @@ DATABASE = mia
|
|||||||
DATABASE_HOST = db.thecoredev.fr
|
DATABASE_HOST = db.thecoredev.fr
|
||||||
DATABASE_PORT = 3306
|
DATABASE_PORT = 3306
|
||||||
DATABASE_USER = mia
|
DATABASE_USER = mia
|
||||||
DATABASE_PASSWORD = CalomOk0t-ISvpw-
|
DATABASE_PASSWORD = CalomOk0t-ISvpw-
|
||||||
|
|
||||||
|
MASTER_URL = 'https://slave.thecoredev.fr'
|
||||||
|
SLAVE_URL = 'https://slave.thecoredev.fr'
|
||||||
58
app.js
58
app.js
@@ -1,5 +1,5 @@
|
|||||||
const express = require('express')
|
const express = require('express')
|
||||||
const mysql = require("mysql")
|
const mysql = require("mysql2")
|
||||||
const dotenv = require('dotenv')
|
const dotenv = require('dotenv')
|
||||||
const app = express()
|
const app = express()
|
||||||
const path = require("path")
|
const path = require("path")
|
||||||
@@ -30,19 +30,10 @@ db.connect((error) => {
|
|||||||
app.set('view engine', 'hbs');
|
app.set('view engine', 'hbs');
|
||||||
app.use(express.static(publicDir));
|
app.use(express.static(publicDir));
|
||||||
app.use('/css', express.static(__dirname + '/node_modules/bootstrap/dist/css'));
|
app.use('/css', express.static(__dirname + '/node_modules/bootstrap/dist/css'));
|
||||||
|
app.use('/css', express.static(__dirname + '/node_modules/@eonasdan/tempus-dominus/dist/css'));
|
||||||
|
app.use('/js', express.static(__dirname + '/node_modules/@eonasdan/tempus-dominus/dist/js'));
|
||||||
app.use(bodyParser.urlencoded({extended: false}));
|
app.use(bodyParser.urlencoded({extended: false}));
|
||||||
app.use(express.json())
|
app.use(bodyParser.json());
|
||||||
|
|
||||||
|
|
||||||
async function recupListeSessions() {
|
|
||||||
let today = functions.getNowDate("yyyymmdd");
|
|
||||||
|
|
||||||
// On récupère la liste des sessions actives et pour lesquelles il reste de la place
|
|
||||||
db.query('SELECT ID, topic, DATE_FORMAT(scheduled_on, "%d/%m/%Y") as "date", DATE_FORMAT(scheduled_on, "%Hh%i") as "heure", IF(nb_of_attended-nb_of_participants=0, true, false) as "maxAtteint" FROM session WHERE DATE_FORMAT(scheduled_on, "%Y%m%d") >= ?', [today], async (error, result) => {
|
|
||||||
if(error){ console.log(error); }
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ******************************************* Arrivée sur la page d'accueil *******************************************
|
// ******************************************* Arrivée sur la page d'accueil *******************************************
|
||||||
@@ -63,9 +54,7 @@ app.get("/", (req, res) => {
|
|||||||
|
|
||||||
app.get("/index", (req, res) => { res.render("index") });
|
app.get("/index", (req, res) => { res.render("index") });
|
||||||
app.get("/login", (req, res) => { res.render("login") });
|
app.get("/login", (req, res) => { res.render("login") });
|
||||||
app.get("/register", (req, res) => {
|
app.get("/register", (req, res) => { res.render("register", { session: req.query.s, role: req.query.r}) });
|
||||||
res.render("register", { session: req.query.s, role: req.query.r})
|
|
||||||
});
|
|
||||||
app.get("/create-session", (req, res) => { res.render("create-session") });
|
app.get("/create-session", (req, res) => { res.render("create-session") });
|
||||||
|
|
||||||
|
|
||||||
@@ -164,12 +153,8 @@ app.post("/auth/check-login-no-security", (req, res) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role == 'A') {
|
if (role == 'A') { res.redirect(process.env.MASTER_URL); }
|
||||||
res.redirect('https://slave.thecoredev.fr');
|
else { res.redirect(process.env.SLAVE_URL); }
|
||||||
}
|
|
||||||
else {
|
|
||||||
res.redirect('https://slave.thecoredev.fr');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -210,13 +195,10 @@ app.post("/auth/check-login", (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
userId = result[0].ID;
|
userId = result[0].ID;
|
||||||
if (functions.comparePassword(password, result[0].password)) {
|
|
||||||
// Le user est connecté avec succès : on vérifie qu'il n'est pas déjà inscrit à la session et si pas le cas, on l'inscrit et on incrémente le compteur des participants
|
|
||||||
db.query('SELECT * FROM participation WHERE user = ?', [userId], async (error, result) => {
|
|
||||||
if(error) {
|
|
||||||
console.log(error)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
bcrypt.compare(password, result[0].password)
|
||||||
|
.then(result => {
|
||||||
|
if (result) {
|
||||||
if (result.length == 0) {
|
if (result.length == 0) {
|
||||||
db.query('INSERT INTO participation (user, session, role_during_session) VALUES (?,?,?)', [userId, session[0], role[0]], function (err, result) {
|
db.query('INSERT INTO participation (user, session, role_during_session) VALUES (?,?,?)', [userId, session[0], role[0]], function (err, result) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
@@ -228,22 +210,18 @@ app.post("/auth/check-login", (req, res) => {
|
|||||||
console.log("1 record updated");
|
console.log("1 record updated");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
if (role == 'A') {
|
if (role == 'A') { res.redirect('https://slave.thecoredev.fr'); }
|
||||||
res.redirect('https://slave.thecoredev.fr');
|
else { res.redirect('https://slave.thecoredev.fr'); }
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res.redirect('https://slave.thecoredev.fr');
|
return res.render('login', {
|
||||||
|
error: 'Mot de passe incorrect : corriger votre saisie',
|
||||||
|
session: session,
|
||||||
|
role: role
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
else {
|
|
||||||
return res.render('login', {
|
|
||||||
error: 'Mot de passe incorrect : corriger votre saisie',
|
|
||||||
"session": session,
|
|
||||||
"role": role
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"start": "nodemon --inspect app.js"
|
"start": "nodemon app.js"
|
||||||
},
|
},
|
||||||
"author": "Laurent LE CORRE",
|
"author": "Laurent LE CORRE",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
// DatePicker sur l'écran de création d'une session
|
// DatePicker sur l'écran de création d'une session
|
||||||
window.datetimepicker1 = $('#datetimepicker1');
|
window.datetimepicker1 = $('#datetimepicker1');
|
||||||
|
|
||||||
datetimepicker1.tempusDominus({
|
datetimepicker1.tempusDominus({
|
||||||
//put your config here
|
|
||||||
allowInputToggle: true,
|
allowInputToggle: true,
|
||||||
stepping: 15,
|
stepping: 15,
|
||||||
localization: {
|
localization: {
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.7.10/dist/js/tempus-dominus.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.7.10/dist/js/tempus-dominus.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.7.10/dist/js/jQuery-provider.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.7.10/dist/js/jQuery-provider.js"></script>
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.7.10/dist/css/tempus-dominus.css" />
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@eonasdan/tempus-dominus@6.7.10/dist/css/tempus-dominus.css" />
|
||||||
<script type="module" src="/scripts-session.js"></script>
|
<script type="module" src="/session.js"></script>
|
||||||
</head>
|
</head>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Reference in New Issue
Block a user