From fbd10c6fd5ff68e3bb437f663e6e964cf360b65b Mon Sep 17 00:00:00 2001 From: ExostFlash Date: Fri, 29 Aug 2025 10:33:03 +0200 Subject: [PATCH] modif all --- database.sqlite | Bin 12288 -> 12288 bytes db_init.js | 21 ------------ modules/auth/google.js | 7 ++-- public/resto.css | 4 +-- routes.js | 29 +++++++---------- views/resto.ejs | 71 ++++++++++++++++++++++++++++++++++++++++- 6 files changed, 87 insertions(+), 45 deletions(-) diff --git a/database.sqlite b/database.sqlite index 1b9cafb9fb61da9a43eddae3c03f0492f1b56d3e..d1ecd14a33e15a2934fa4b09afed5c44193d2c3f 100644 GIT binary patch delta 188 zcmZojXh@hK&B#1a#+i|MW5N=Cb|!uX2L1;A&4L17`RePKI2g)iz3W}}t^>Z?e_0se6({oZwi&Kk|^Ycnl^GfuR^Kv%*=f<(~FE { - const db = new sqlite3.Database(dbPath, (err) => { - if (err) { - reject(err); - } else { - db.run(` - CREATE TABLE IF NOT EXISTS restaurants ( - id INTEGER PRIMARY KEY, - nom TEXT NOT NULL, - description TEXT, - adresse TEXT NOT NULL, - menu TEXT - ); - `); - } - db.close(); - resolve(); - }); - }); -}; module.exports = initDb; diff --git a/modules/auth/google.js b/modules/auth/google.js index f0bb22b..ff363dd 100644 --- a/modules/auth/google.js +++ b/modules/auth/google.js @@ -1,13 +1,14 @@ const axios = require("axios"); -const { getUserByDId } = require('../users/getUsers'); +const { getUserByGId } = require('../users/getUsers'); const { postUser } = require('../users/postUsers'); const CLIEN_ID = "71229835507-9413gbpdamv2qbcb2ov8oda2oqgcsk8q.apps.googleusercontent.com"; const GOOGLE_SECRET = "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"; -const REDIRECT_URI = "http://localhost:3000/auth/google/callback"; +const GOOGLE_REDIRECT_URI = "http://localhost:3000/auth/google/callback"; -exports.handleGoogleAuth = async (code, res) => { +exports.handleGoogleAuth = async (req, res) => { + const code = req.query.code; if (!code) return res.status(400).json({ error: "Code de validation manquant" }); try { const params = new URLSearchParams(); diff --git a/public/resto.css b/public/resto.css index d1f27df..7224c3b 100644 --- a/public/resto.css +++ b/public/resto.css @@ -49,8 +49,8 @@ main { } .chart-placeholder { - width: 150px; - height: 150px; + width: 200px; + height: 200px; background: #eee; display: flex; align-items: center; diff --git a/routes.js b/routes.js index a10b046..86b422d 100644 --- a/routes.js +++ b/routes.js @@ -22,6 +22,17 @@ router.get('/auth/discord', (req, res) => { router.get('/auth/discord/callback', require('./modules/auth/discord').handleDiscordAuth); +// Auth Google +router.get('/auth/google', (req, res) => { + const clientId = '71229835507-9413gbpdamv2qbcb2ov8oda2oqgcsk8q.apps.googleusercontent.com'; + const redirectUri = 'http://localhost:3000/auth/google/callback'; + const scope = 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile'; + const googleAuthUrl = `https://accounts.google.com/o/oauth2/auth?client_id=${clientId}&redirect_uri=${encodeURIComponent(redirectUri)}&response_type=code&scope=${encodeURIComponent(scope)}`; + res.redirect(googleAuthUrl); +}); + +router.get('/auth/google/callback', require('./modules/auth/google').handleGoogleAuth); + // Déconnexion router.get('/logout', (req, res) => { req.session.destroy((err) => { @@ -33,22 +44,4 @@ router.get('/logout', (req, res) => { }); }); - - -// Infos resto -router.get('/restaurants/:id', async (req, res) => { - const id = req.params.id; - try { - const restaurant = await db.get(`SELECT * FROM restaurants WHERE id = ?`, [id]); - if (!restaurant) { - res.status(404).send('Restaurant non trouvé'); - } else { - res.render('restaurant', { restaurant }); - } - } catch (err) { - console.error(err); - res.status(500).send('Erreur lors de la récupération des informations du restaurant'); - } -}); - module.exports = router; \ No newline at end of file diff --git a/views/resto.ejs b/views/resto.ejs index 00a0dd1..ebd3625 100644 --- a/views/resto.ejs +++ b/views/resto.ejs @@ -21,7 +21,9 @@
-
Graph radar
+
+ +
@@ -95,3 +97,70 @@ + + + + \ No newline at end of file