mirror of
https://scm.univ-tours.fr/22107988t/rappaurio-sae501_502.git
synced 2025-05-30 20:45:41 +02:00
unstable update
This commit is contained in:
parent
8cbb6dcc01
commit
9887a6f445
@ -402,11 +402,11 @@ $(document).ready(function () {
|
||||
|
||||
// Mettez à jour la section HTML avec les données reçues ici
|
||||
|
||||
// Rediriger l'utilisateur vers la page de connexion
|
||||
window.location.href = "/connexion";
|
||||
// Rediriger l'utilisateur vers la page de connexion
|
||||
window.location.href = "/connexion";
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
error: function (error) {
|
||||
@ -420,6 +420,65 @@ $(document).ready(function () {
|
||||
});
|
||||
});
|
||||
|
||||
// Sélectionnez le formulaire de CONNEXION par son ID
|
||||
$('#formulaire-inscription').submit(function (e) {
|
||||
|
||||
|
||||
// Empêchez la soumission normale du formulaire
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
// Reste du code pour gérer la soumission du formulaire
|
||||
//console.log('Formulaire soumis !');
|
||||
|
||||
// Récupérez les valeurs des champs du formulaire
|
||||
const name = $('#name').val();
|
||||
const email = $('#email').val();
|
||||
const password = $('#password').val();
|
||||
|
||||
// Créez un objet JavaScript avec les données à envoyer au serveur
|
||||
const formData = {
|
||||
name: name,
|
||||
email: email,
|
||||
password: password
|
||||
};
|
||||
|
||||
// Utilisez AJAX pour envoyer les données au serveur
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/connexion',
|
||||
data: formData,
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
console.log(response);
|
||||
|
||||
// Vérifiez si la réponse contient le token (utilisez la clé appropriée)
|
||||
if (response.token) {
|
||||
// Récupérez le token de la réponse JSON
|
||||
const token = response.token;
|
||||
|
||||
console.log(token);
|
||||
|
||||
// Définissez le cookie avec un chemin approprié
|
||||
// Par exemple, le chemin '/' signifie que le cookie est valide pour tout le site
|
||||
document.cookie = `token=${token}`;
|
||||
} else {
|
||||
console.error('Token non trouvé dans la réponse JSON.');
|
||||
}
|
||||
|
||||
// Mettez à jour la section HTML avec les données reçues ici
|
||||
|
||||
},
|
||||
error: function (error) {
|
||||
console.error('Erreur :', error);
|
||||
|
||||
// Ajoutez une console.log pour vérifier si cette partie du code est exécutée
|
||||
console.log('Erreur AJAX');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
@ -609,3 +668,4 @@ $(document).ready(function () {
|
||||
|
||||
|
||||
|
||||
|
||||
|
135
app/index.js
135
app/index.js
@ -1,13 +1,7 @@
|
||||
// === Liens utiles pour gestion users
|
||||
|
||||
// https://jasonwatmore.com/post/2018/11/28/nodejs-role-based-authorization-tutorial-with-example-api
|
||||
|
||||
// https://github.com/cornflourblue/node-role-based-authorization-api/tree/master
|
||||
|
||||
// ---------------------------------------------------
|
||||
|
||||
const express = require('express');
|
||||
const exphbs = require('express-handlebars');
|
||||
const session = require('express-session');
|
||||
const MySQLStore = require('connect-mysql')(session);
|
||||
const path = require('path');
|
||||
const cookieParser = require('cookie-parser');
|
||||
const axios = require('axios');
|
||||
@ -19,7 +13,10 @@ const morgan = require('morgan');
|
||||
app.use(morgan('dev'));
|
||||
const mysql = require('mysql2');
|
||||
const dotenv = require('dotenv');
|
||||
dotenv.config({ path: '../.env' });
|
||||
const jwt = require('jsonwebtoken');
|
||||
// get config vars
|
||||
dotenv.config();
|
||||
|
||||
|
||||
|
||||
// Configuration du moteur de modèle Handlebars
|
||||
@ -33,25 +30,15 @@ app.use(express.static(path.join(__dirname, '/')));
|
||||
// Utilisation de cookie-parser comme middleware
|
||||
app.use(cookieParser());
|
||||
|
||||
// Middleware pour gérer le thème basé sur le cookie
|
||||
|
||||
/*
|
||||
app.use((req, res, next) => {
|
||||
if (req.cookies.theme === 'dark') {
|
||||
// Si le cookie "theme" est défini sur "dark", ajoutez la classe "dark" au <html>
|
||||
res.locals.theme = 'dark';
|
||||
} else {
|
||||
// Sinon, retirez la classe "dark"
|
||||
res.locals.theme = '';
|
||||
}
|
||||
next();
|
||||
});
|
||||
*/
|
||||
|
||||
// Middleware body-parser pour traiter les données POST du formulaire
|
||||
app.use(bodyParser.urlencoded({ extended: false }));
|
||||
|
||||
// ================ FONCTIONS ==============================
|
||||
// ============================= FONCTIONS ========================================================
|
||||
|
||||
// Génère un token
|
||||
function generateAccessToken(username) {
|
||||
return jwt.sign(username, process.env.TOKEN_SECRET, { expiresIn: '1800s' });
|
||||
}
|
||||
|
||||
// Fonction de nettoyage personnalisée (pour infobox)
|
||||
function cleanInfoboxText(text) {
|
||||
@ -70,6 +57,8 @@ function cleanInfoboxText(text) {
|
||||
return finalText.trim();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Fonction pour récupérer les informations d'un article depuis l'API MediaWiki
|
||||
async function fetchArticleInfoFromAPI(articleTitle) {
|
||||
try {
|
||||
@ -116,7 +105,8 @@ async function fetchArticleInfoFromAPI(articleTitle) {
|
||||
const page_data = await wiki.page(articleTitle);
|
||||
const parsed = page_data.parse();
|
||||
|
||||
const variablesExclues = ['image', 'blason', 'drapeau', 'logo', 'légende', 'carte', 'légende-carte', 'Site-Internet', 'siteweb', '_', 'statut', 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
// Filtre des données compliquée à représentée
|
||||
const variablesExclues = ['image', 'blason', 'drapeau', 'logo', 'légende', 'carte', 'légende-carte', '_', 'statut', 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
|
||||
// Lire les modèles Infobox, les convertir en JSON.
|
||||
parsed.each('template', (template_token) => {
|
||||
@ -198,7 +188,7 @@ async function fetchArticleInfoFromAPI(articleTitle) {
|
||||
return articleInfo;
|
||||
}
|
||||
} else {
|
||||
console.log(`Warning :l'article "${articleTitle}" n'a pas été trouvé.`);
|
||||
console.log(`Warning : l'article "${articleTitle}" n'a pas été trouvé.`);
|
||||
return null;
|
||||
}
|
||||
} catch (error) {
|
||||
@ -207,17 +197,14 @@ async function fetchArticleInfoFromAPI(articleTitle) {
|
||||
}
|
||||
}
|
||||
|
||||
// ===================== ROUTES ==========================
|
||||
// ============================= ROUTES ===========================================================
|
||||
|
||||
// Index
|
||||
app.get('/', async (req, res) => {
|
||||
|
||||
// Renvoyez la page index avec les informations de l'article et de l'infobox
|
||||
res.render('contains/index', { pageTitle: 'Accueil' });
|
||||
|
||||
});
|
||||
|
||||
|
||||
// Comparaison d'articles
|
||||
app.post('/search', async (req, res) => {
|
||||
try {
|
||||
@ -248,22 +235,16 @@ app.post('/connexion', async (req, res) => {
|
||||
// Récupérez les données du formulaire depuis req.body
|
||||
const ClientEmail = req.body.email;
|
||||
const ClientPassword = req.body.password;
|
||||
console.log("Succès : " + ClientEmail + " " + ClientPassword);
|
||||
//console.log("Succès : " + ClientEmail + " " + ClientPassword);
|
||||
|
||||
// config de la connexion à la BDD
|
||||
var connection = mysql.createConnection({
|
||||
host: 'localhost',
|
||||
//user: process.env.MYSQL_USER,
|
||||
//password: process.env.MYSQL_PASSWORD,
|
||||
//database: process.env.MYSQL_DB
|
||||
user: 'radar',
|
||||
password: 'changeme',
|
||||
database: 'rappaurio'
|
||||
user: process.env.MYSQL_USER,
|
||||
password: process.env.MYSQL_PASSWORD,
|
||||
database: process.env.MYSQL_DB
|
||||
});
|
||||
|
||||
const conn = await connection();
|
||||
const [rows] = await conn.execute('SELECT * FROM media');
|
||||
|
||||
// Connexion à la BDD
|
||||
connection.connect(function (err) {
|
||||
if (err) {
|
||||
@ -280,7 +261,7 @@ app.post('/connexion', async (req, res) => {
|
||||
}
|
||||
|
||||
// Vérification si l'utilisateur est correct
|
||||
let ValidationConnection = 'NON';
|
||||
let ValidationConnection = '';
|
||||
|
||||
for (const row of results) {
|
||||
const BddEmail = row.email;
|
||||
@ -288,12 +269,32 @@ app.post('/connexion', async (req, res) => {
|
||||
|
||||
if (BddEmail === ClientEmail && BddPassword === ClientPassword) {
|
||||
ValidationConnection = 'OK';
|
||||
break; // Sortez de la boucle dès que vous avez trouvé une correspondance
|
||||
break; // Sort de la boucle dès qu'il y a une correspondance
|
||||
}
|
||||
}
|
||||
|
||||
// Renvoyez la réponse au format JSON
|
||||
res.json({ ValidationConnection });
|
||||
if (ValidationConnection !== 'OK') {
|
||||
ValidationConnection = 'WrongID';
|
||||
}
|
||||
else {
|
||||
const token = generateAccessToken({ username: ClientEmail });
|
||||
//console.log(token);
|
||||
|
||||
res.json({token});
|
||||
|
||||
connection.query("INSERT INTO sessions (session_id, email) VALUES (?, ?)", [token, ClientEmail], (err, results, fields) => {
|
||||
if (err) {
|
||||
console.error('Erreur lors de l\'exécution de la requête :', err);
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Fermeture de la BDD
|
||||
connection.end(function (err) {
|
||||
@ -311,7 +312,6 @@ app.post('/connexion', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Inscription
|
||||
app.get('/inscription', (req, res) => {
|
||||
res.render('contains/signup', { pageTitle: 'Inscription' });
|
||||
@ -327,12 +327,9 @@ app.post('/inscription', async (req, res) => {
|
||||
// config de la connexion à la BDD
|
||||
var connection = mysql.createConnection({
|
||||
host: 'localhost',
|
||||
//user: process.env.MYSQL_USER,
|
||||
//password: process.env.MYSQL_PASSWORD,
|
||||
//database: process.env.MYSQL_DB
|
||||
user: 'radar',
|
||||
password: 'changeme',
|
||||
database: 'rappaurio'
|
||||
user: process.env.MYSQL_USER,
|
||||
password: process.env.MYSQL_PASSWORD,
|
||||
database: process.env.MYSQL_DB
|
||||
});
|
||||
|
||||
// Connexion à la BDD
|
||||
@ -348,7 +345,6 @@ app.post('/inscription', async (req, res) => {
|
||||
console.error('Erreur lors de l\'exécution de la requête :', err);
|
||||
throw err;
|
||||
}
|
||||
//console.log('Résultats de la requête :', results);
|
||||
|
||||
let ValidationInscription = '';
|
||||
|
||||
@ -357,23 +353,18 @@ app.post('/inscription', async (req, res) => {
|
||||
|
||||
if (BddEmail === ClientEmail) {
|
||||
ValidationInscription = 'Doublon';
|
||||
break; // Sort de la boucle dès qu'il y à une correspondance
|
||||
break; // Sort de la boucle dès qu'il y a une correspondance
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (ValidationInscription !== 'Doublon') {
|
||||
|
||||
// Requète BDD qui insert les données
|
||||
// Requète BDD qui insère les données
|
||||
connection.query("INSERT INTO User (name, email, password) VALUES (?, ?, ?)", [name, ClientEmail, ClientPassword], (err, results, fields) => {
|
||||
if (err) {
|
||||
console.error('Erreur lors de l\'exécution de la requête :', err);
|
||||
throw err;
|
||||
}
|
||||
//console.log('Résultats de la requête :', results);
|
||||
|
||||
});
|
||||
|
||||
ValidationInscription = 'OK';
|
||||
}
|
||||
console.log(ValidationInscription);
|
||||
@ -386,9 +377,7 @@ app.post('/inscription', async (req, res) => {
|
||||
console.log('Connexion à la base de données fermée.');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
@ -396,39 +385,21 @@ app.post('/inscription', async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Historique
|
||||
app.get('/historique', (req, res) => {
|
||||
res.render('contains/historique', { pageTitle: 'Historique' });
|
||||
});
|
||||
|
||||
|
||||
/* EXEMPLE UTILISATION COOKIE
|
||||
|
||||
// Changer le thème en fonction de la case cochée
|
||||
app.post('/toggle-theme', (req, res) => {
|
||||
if (req.cookies.theme === 'dark') {
|
||||
// Si le thème est actuellement "dark", changez-le en "light"
|
||||
res.cookie('theme', 'light', { sameSite: 'None', secure: true });
|
||||
} else {
|
||||
// Sinon, changez-le en "dark"
|
||||
res.cookie('theme', 'dark', { sameSite: 'None', secure: true });
|
||||
}
|
||||
res.redirect(req.get('referer'));
|
||||
});
|
||||
*/
|
||||
|
||||
|
||||
// 404
|
||||
app.use((req, res, next) => {
|
||||
res.status(404).render('contains/404', { title: 'Erreur 404' });
|
||||
});
|
||||
|
||||
|
||||
// ============================= PORT ============================================================
|
||||
|
||||
// ======================== PORT ===========================
|
||||
|
||||
// Port
|
||||
const PORT = process.env.PORT || 5000;
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Info : le serveur est en écoute sur le port ${PORT}`);
|
||||
|
309
app/package-lock.json
generated
309
app/package-lock.json
generated
@ -11,11 +11,15 @@
|
||||
"dependencies": {
|
||||
"axios": "^1.5.0",
|
||||
"body-parser": "^1.20.2",
|
||||
"connect-mysql": "^4.0.0",
|
||||
"cookie-parser": "^1.4.6",
|
||||
"crypto": "^1.0.1",
|
||||
"dotenv": "^16.3.1",
|
||||
"express": "^4.18.2",
|
||||
"express-handlebars": "^7.1.2",
|
||||
"express-session": "^1.17.3",
|
||||
"hbs": "^4.2.0",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"morgan": "^1.10.0",
|
||||
"mysql2": "^3.6.1",
|
||||
"wikiapi": "^1.19.4",
|
||||
@ -86,6 +90,17 @@
|
||||
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
||||
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
|
||||
},
|
||||
"node_modules/asn1.js": {
|
||||
"version": "5.4.1",
|
||||
"resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz",
|
||||
"integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==",
|
||||
"dependencies": {
|
||||
"bn.js": "^4.0.0",
|
||||
"inherits": "^2.0.1",
|
||||
"minimalistic-assert": "^1.0.0",
|
||||
"safer-buffer": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
@ -122,6 +137,19 @@
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||
},
|
||||
"node_modules/bignumber.js": {
|
||||
"version": "9.0.0",
|
||||
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz",
|
||||
"integrity": "sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/bn.js": {
|
||||
"version": "4.12.0",
|
||||
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz",
|
||||
"integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA=="
|
||||
},
|
||||
"node_modules/body-parser": {
|
||||
"version": "1.20.2",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz",
|
||||
@ -153,6 +181,11 @@
|
||||
"balanced-match": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/buffer-equal-constant-time": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
|
||||
"integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="
|
||||
},
|
||||
"node_modules/bytes": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
|
||||
@ -216,6 +249,18 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/connect-mysql": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/connect-mysql/-/connect-mysql-4.0.0.tgz",
|
||||
"integrity": "sha512-aqXUaWEqi7KujGSmETMey2bzbw1+qCH/v4ZYMjRCut6lJN+rv77+jxzFh+ONYOH9yorVlCmH+ZRbtG4LfQV1WA==",
|
||||
"dependencies": {
|
||||
"kruptein": "^2.0.7",
|
||||
"mysql": "^2.18.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">6"
|
||||
}
|
||||
},
|
||||
"node_modules/content-disposition": {
|
||||
"version": "0.5.4",
|
||||
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
|
||||
@ -260,6 +305,11 @@
|
||||
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
|
||||
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
|
||||
},
|
||||
"node_modules/core-util-is": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
|
||||
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
|
||||
},
|
||||
"node_modules/cross-fetch": {
|
||||
"version": "3.1.8",
|
||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz",
|
||||
@ -281,6 +331,12 @@
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/crypto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz",
|
||||
"integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==",
|
||||
"deprecated": "This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in."
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
@ -338,6 +394,14 @@
|
||||
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
|
||||
"integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA=="
|
||||
},
|
||||
"node_modules/ecdsa-sig-formatter": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
|
||||
"integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
|
||||
"dependencies": {
|
||||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
|
||||
@ -423,6 +487,32 @@
|
||||
"node": ">=v16"
|
||||
}
|
||||
},
|
||||
"node_modules/express-session": {
|
||||
"version": "1.17.3",
|
||||
"resolved": "https://registry.npmjs.org/express-session/-/express-session-1.17.3.tgz",
|
||||
"integrity": "sha512-4+otWXlShYlG1Ma+2Jnn+xgKUZTMJ5QD3YvfilX3AcocOAbIkVylSWEklzALe/+Pu4qV6TYBj5GwOBFfdKqLBw==",
|
||||
"dependencies": {
|
||||
"cookie": "0.4.2",
|
||||
"cookie-signature": "1.0.6",
|
||||
"debug": "2.6.9",
|
||||
"depd": "~2.0.0",
|
||||
"on-headers": "~1.0.2",
|
||||
"parseurl": "~1.3.3",
|
||||
"safe-buffer": "5.2.1",
|
||||
"uid-safe": "~2.1.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/express-session/node_modules/cookie": {
|
||||
"version": "0.4.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz",
|
||||
"integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/express/node_modules/body-parser": {
|
||||
"version": "1.20.1",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
|
||||
@ -765,6 +855,11 @@
|
||||
"resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz",
|
||||
"integrity": "sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g=="
|
||||
},
|
||||
"node_modules/isarray": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ=="
|
||||
},
|
||||
"node_modules/isexe": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||
@ -787,6 +882,97 @@
|
||||
"@pkgjs/parseargs": "^0.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jsonwebtoken": {
|
||||
"version": "9.0.2",
|
||||
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz",
|
||||
"integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==",
|
||||
"dependencies": {
|
||||
"jws": "^3.2.2",
|
||||
"lodash.includes": "^4.3.0",
|
||||
"lodash.isboolean": "^3.0.3",
|
||||
"lodash.isinteger": "^4.0.4",
|
||||
"lodash.isnumber": "^3.0.3",
|
||||
"lodash.isplainobject": "^4.0.6",
|
||||
"lodash.isstring": "^4.0.1",
|
||||
"lodash.once": "^4.0.0",
|
||||
"ms": "^2.1.1",
|
||||
"semver": "^7.5.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12",
|
||||
"npm": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/jsonwebtoken/node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
||||
},
|
||||
"node_modules/jwa": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz",
|
||||
"integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==",
|
||||
"dependencies": {
|
||||
"buffer-equal-constant-time": "1.0.1",
|
||||
"ecdsa-sig-formatter": "1.0.11",
|
||||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/jws": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz",
|
||||
"integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==",
|
||||
"dependencies": {
|
||||
"jwa": "^1.4.1",
|
||||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/kruptein": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/kruptein/-/kruptein-2.2.3.tgz",
|
||||
"integrity": "sha512-BTwprBPTzkFT9oTugxKd3WnWrX630MqUDsnmBuoa98eQs12oD4n4TeI0GbpdGcYn/73Xueg2rfnw+oK4dovnJg==",
|
||||
"dependencies": {
|
||||
"asn1.js": "^5.4.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">6"
|
||||
}
|
||||
},
|
||||
"node_modules/lodash.includes": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
|
||||
"integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w=="
|
||||
},
|
||||
"node_modules/lodash.isboolean": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz",
|
||||
"integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg=="
|
||||
},
|
||||
"node_modules/lodash.isinteger": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz",
|
||||
"integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA=="
|
||||
},
|
||||
"node_modules/lodash.isnumber": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
|
||||
"integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw=="
|
||||
},
|
||||
"node_modules/lodash.isplainobject": {
|
||||
"version": "4.0.6",
|
||||
"resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
|
||||
"integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA=="
|
||||
},
|
||||
"node_modules/lodash.isstring": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz",
|
||||
"integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw=="
|
||||
},
|
||||
"node_modules/lodash.once": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
|
||||
"integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg=="
|
||||
},
|
||||
"node_modules/long": {
|
||||
"version": "5.2.3",
|
||||
"resolved": "https://registry.npmjs.org/long/-/long-5.2.3.tgz",
|
||||
@ -851,6 +1037,11 @@
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/minimalistic-assert": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz",
|
||||
"integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A=="
|
||||
},
|
||||
"node_modules/minimatch": {
|
||||
"version": "9.0.3",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz",
|
||||
@ -912,6 +1103,33 @@
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
|
||||
},
|
||||
"node_modules/mysql": {
|
||||
"version": "2.18.1",
|
||||
"resolved": "https://registry.npmjs.org/mysql/-/mysql-2.18.1.tgz",
|
||||
"integrity": "sha512-Bca+gk2YWmqp2Uf6k5NFEurwY/0td0cpebAucFpY/3jhrwrVGuxU2uQFCHjU19SJfje0yQvi+rVWdq78hR5lig==",
|
||||
"dependencies": {
|
||||
"bignumber.js": "9.0.0",
|
||||
"readable-stream": "2.3.7",
|
||||
"safe-buffer": "5.1.2",
|
||||
"sqlstring": "2.3.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mysql/node_modules/safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||
},
|
||||
"node_modules/mysql/node_modules/sqlstring": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz",
|
||||
"integrity": "sha512-ooAzh/7dxIG5+uDik1z/Rd1vli0+38izZhGzSa34FwR7IbelPWCCKSNIl8jlL/F7ERvy8CB2jNeM1E9i9mXMAQ==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mysql2": {
|
||||
"version": "3.6.1",
|
||||
"resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.6.1.tgz",
|
||||
@ -1063,6 +1281,11 @@
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
|
||||
"integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ=="
|
||||
},
|
||||
"node_modules/process-nextick-args": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
|
||||
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
|
||||
},
|
||||
"node_modules/proxy-addr": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
|
||||
@ -1094,6 +1317,14 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/random-bytes": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz",
|
||||
"integrity": "sha512-iv7LhNVO047HzYR3InF6pUcUsPQiHTM1Qal51DcGSuZFBil1aBBWG5eHPNek7bvILMaYJ/8RU1e8w1AMdHmLQQ==",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/range-parser": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
|
||||
@ -1116,6 +1347,25 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/readable-stream": {
|
||||
"version": "2.3.7",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
|
||||
"integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
|
||||
"dependencies": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~2.0.0",
|
||||
"safe-buffer": "~5.1.1",
|
||||
"string_decoder": "~1.1.1",
|
||||
"util-deprecate": "~1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/readable-stream/node_modules/safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||
},
|
||||
"node_modules/safe-buffer": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||
@ -1140,6 +1390,31 @@
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"node_modules/semver": {
|
||||
"version": "7.5.4",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
|
||||
"integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
|
||||
"dependencies": {
|
||||
"lru-cache": "^6.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/semver/node_modules/lru-cache": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||
"dependencies": {
|
||||
"yallist": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/send": {
|
||||
"version": "0.18.0",
|
||||
"resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz",
|
||||
@ -1259,6 +1534,19 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"dependencies": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/string_decoder/node_modules/safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||
},
|
||||
"node_modules/string-width": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",
|
||||
@ -1378,6 +1666,17 @@
|
||||
"node": ">=0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uid-safe": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz",
|
||||
"integrity": "sha512-KPHm4VL5dDXKz01UuEd88Df+KzynaohSL9fBh096KWAxSKZQDI2uBrVqtvRM4rwrIrRRKsdLNML/lnaaVSRioA==",
|
||||
"dependencies": {
|
||||
"random-bytes": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/unpipe": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||
@ -1386,6 +1685,11 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
|
||||
},
|
||||
"node_modules/utils-merge": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
||||
@ -1548,6 +1852,11 @@
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/yallist": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,15 @@
|
||||
"dependencies": {
|
||||
"axios": "^1.5.0",
|
||||
"body-parser": "^1.20.2",
|
||||
"connect-mysql": "^4.0.0",
|
||||
"cookie-parser": "^1.4.6",
|
||||
"crypto": "^1.0.1",
|
||||
"dotenv": "^16.3.1",
|
||||
"express": "^4.18.2",
|
||||
"express-handlebars": "^7.1.2",
|
||||
"express-session": "^1.17.3",
|
||||
"hbs": "^4.2.0",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"morgan": "^1.10.0",
|
||||
"mysql2": "^3.6.1",
|
||||
"wikiapi": "^1.19.4",
|
||||
|
@ -22,9 +22,17 @@ CREATE TABLE Search (
|
||||
FOREIGN KEY (id_user) REFERENCES User(id_user)
|
||||
);
|
||||
|
||||
-- Créer la table "sessions"
|
||||
CREATE TABLE Sessions (
|
||||
session_id VARCHAR(255) NOT NULL PRIMARY KEY,
|
||||
email VARCHAR(255) NOT NULL
|
||||
);
|
||||
|
||||
--DROP USER 'radar'@'%';
|
||||
|
||||
-- Créer l'utilsateur
|
||||
CREATE USER IF NOT EXISTS 'radar'@'%' IDENTIFIED BY 'changeme';
|
||||
|
||||
SET PASSWORD FOR 'radar'@'%' = PASSWORD('changeme');
|
||||
|
||||
-- Donne les droits à l'utilisateur pour la BDD spécifiée dans le .env
|
||||
GRANT ALL PRIVILEGES ON rappaurio.* TO 'radar'@'%';
|
||||
|
Loading…
x
Reference in New Issue
Block a user