diff --git a/.env b/.env
index ec3e9e6..f9a2a76 100644
--- a/.env
+++ b/.env
@@ -2,4 +2,7 @@ DATABASE = mia_dev
DATABASE_HOST = db.thecoredev.fr
DATABASE_PORT = 3306
DATABASE_USER = mia
-DATABASE_PASSWORD = CalomOk0t-ISvpw-
\ No newline at end of file
+DATABASE_PASSWORD = CalomOk0t-ISvpw-
+
+MASTER_URL = 'https://slave.thecoredev.fr'
+SLAVE_URL = 'https://slave.thecoredev.fr'
\ No newline at end of file
diff --git a/.env.prod b/.env.prod
index 679c262..31e5a19 100644
--- a/.env.prod
+++ b/.env.prod
@@ -2,4 +2,7 @@ DATABASE = mia
DATABASE_HOST = db.thecoredev.fr
DATABASE_PORT = 3306
DATABASE_USER = mia
-DATABASE_PASSWORD = CalomOk0t-ISvpw-
\ No newline at end of file
+DATABASE_PASSWORD = CalomOk0t-ISvpw-
+
+MASTER_URL = 'https://slave.thecoredev.fr'
+SLAVE_URL = 'https://slave.thecoredev.fr'
\ No newline at end of file
diff --git a/app.js b/app.js
index 2be76ce..27c0de8 100644
--- a/app.js
+++ b/app.js
@@ -54,9 +54,7 @@ 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") });
@@ -155,12 +153,8 @@ app.post("/auth/check-login-no-security", (req, res) => {
});
}
- if (role == 'A') {
- res.redirect('https://slave.thecoredev.fr');
- }
- else {
- res.redirect('https://slave.thecoredev.fr');
- }
+ if (role == 'A') { res.redirect(process.env.MASTER_URL); }
+ else { res.redirect(process.env.SLAVE_URL); }
});
}
});
@@ -201,13 +195,10 @@ 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;
@@ -219,22 +210,18 @@ app.post("/auth/check-login", (req, res) => {
console.log("1 record updated");
});
}
- })
- if (role == 'A') {
- res.redirect('https://slave.thecoredev.fr');
+ if (role == 'A') { res.redirect('https://slave.thecoredev.fr'); }
+ else { res.redirect('https://slave.thecoredev.fr'); }
}
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
- })
- }
+ })
})
})
diff --git a/schema.sql b/schema.sql
new file mode 100644
index 0000000..551d6b3
--- /dev/null
+++ b/schema.sql
@@ -0,0 +1,32 @@
+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 94ede24..8eef75d 100644
--- a/views/create-session.hbs
+++ b/views/create-session.hbs
@@ -6,10 +6,8 @@
-
-