diff --git a/.env b/.env
index f9a2a76..ec3e9e6 100644
--- a/.env
+++ b/.env
@@ -2,7 +2,4 @@ DATABASE = mia_dev
DATABASE_HOST = db.thecoredev.fr
DATABASE_PORT = 3306
DATABASE_USER = mia
-DATABASE_PASSWORD = CalomOk0t-ISvpw-
-
-MASTER_URL = 'https://slave.thecoredev.fr'
-SLAVE_URL = 'https://slave.thecoredev.fr'
\ No newline at end of file
+DATABASE_PASSWORD = CalomOk0t-ISvpw-
\ No newline at end of file
diff --git a/.env.prod b/.env.prod
index 31e5a19..679c262 100644
--- a/.env.prod
+++ b/.env.prod
@@ -2,7 +2,4 @@ DATABASE = mia
DATABASE_HOST = db.thecoredev.fr
DATABASE_PORT = 3306
DATABASE_USER = mia
-DATABASE_PASSWORD = CalomOk0t-ISvpw-
-
-MASTER_URL = 'https://slave.thecoredev.fr'
-SLAVE_URL = 'https://slave.thecoredev.fr'
\ No newline at end of file
+DATABASE_PASSWORD = CalomOk0t-ISvpw-
\ No newline at end of file
diff --git a/app.js b/app.js
index 27c0de8..2be76ce 100644
--- a/app.js
+++ b/app.js
@@ -54,7 +54,9 @@ app.get("/", (req, res) => {
app.get("/index", (req, res) => { res.render("index") });
app.get("/login", (req, res) => { res.render("login") });
-app.get("/register", (req, res) => { res.render("register", { session: req.query.s, role: req.query.r}) });
+app.get("/register", (req, res) => {
+ res.render("register", { session: req.query.s, role: req.query.r})
+});
app.get("/create-session", (req, res) => { res.render("create-session") });
@@ -153,8 +155,12 @@ app.post("/auth/check-login-no-security", (req, res) => {
});
}
- if (role == 'A') { res.redirect(process.env.MASTER_URL); }
- else { res.redirect(process.env.SLAVE_URL); }
+ if (role == 'A') {
+ res.redirect('https://slave.thecoredev.fr');
+ }
+ else {
+ res.redirect('https://slave.thecoredev.fr');
+ }
});
}
});
@@ -195,10 +201,13 @@ app.post("/auth/check-login", (req, res) => {
}
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) {
db.query('INSERT INTO participation (user, session, role_during_session) VALUES (?,?,?)', [userId, session[0], role[0]], function (err, result) {
if (err) throw err;
@@ -210,18 +219,22 @@ app.post("/auth/check-login", (req, res) => {
console.log("1 record updated");
});
}
+ })
- if (role == 'A') { res.redirect('https://slave.thecoredev.fr'); }
- else { res.redirect('https://slave.thecoredev.fr'); }
+ if (role == 'A') {
+ res.redirect('https://slave.thecoredev.fr');
}
else {
- return res.render('login', {
- error: 'Mot de passe incorrect : corriger votre saisie',
- session: session,
- role: role
- })
+ res.redirect('https://slave.thecoredev.fr');
}
- })
+ }
+ else {
+ return res.render('login', {
+ error: 'Mot de passe incorrect : corriger votre saisie',
+ "session": session,
+ "role": role
+ })
+ }
})
})
diff --git a/schema.sql b/schema.sql
deleted file mode 100644
index 551d6b3..0000000
--- a/schema.sql
+++ /dev/null
@@ -1,32 +0,0 @@
-CREATE DATABASE `mia`;
-
-USE `mia`;
-
-CREATE TABLE `participation` (
- `user` uuid DEFAULT NULL,
- `session` uuid DEFAULT NULL,
- `role_during_session` varchar(100) DEFAULT 'A'
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
-
-CREATE TABLE `session` (
- `id` uuid NOT NULL,
- `scheduled_on` datetime DEFAULT NULL,
- `topic` varchar(100) DEFAULT NULL,
- `password` varchar(255) DEFAULT NULL,
- `nb_of_attended` int(11) DEFAULT NULL,
- `nb_of_participants` int(11) DEFAULT 0,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
-
-CREATE TABLE `user` (
- `id` uuid NOT NULL,
- `name` varchar(30) DEFAULT NULL,
- `firstname` varchar(50) DEFAULT NULL,
- `nickname` varchar(100) DEFAULT NULL,
- `title` varchar(100) DEFAULT NULL,
- `gender` varchar(1) DEFAULT NULL,
- `email` varchar(200) DEFAULT NULL,
- `password` varchar(255) DEFAULT NULL,
- `session` uuid DEFAULT NULL,
- PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
\ No newline at end of file
diff --git a/views/create-session.hbs b/views/create-session.hbs
index 8eef75d..94ede24 100644
--- a/views/create-session.hbs
+++ b/views/create-session.hbs
@@ -6,8 +6,10 @@
+
+