diff options
Diffstat (limited to 'controllers')
-rw-r--r-- | controllers/games/gameId.js | 8 | ||||
-rw-r--r-- | controllers/games/root.js | 22 | ||||
-rw-r--r-- | controllers/root/login.js | 22 | ||||
-rw-r--r-- | controllers/root/logout.js | 4 | ||||
-rw-r--r-- | controllers/root/root.js | 4 |
5 files changed, 30 insertions, 30 deletions
diff --git a/controllers/games/gameId.js b/controllers/games/gameId.js index d3363fd..9487743 100644 --- a/controllers/games/gameId.js +++ b/controllers/games/gameId.js @@ -1,8 +1,8 @@ -import { getGame } from "../../database/games.js"; +import { getGame } from '../../database/games.js'; function makePageData(user, game) { return { - title: "Jouer", + title: 'Jouer', user: user, data: game, }; @@ -18,7 +18,7 @@ export function gameId_get(req, res) { game.letters = game.player2.letters; delete game.player1.letters; } - return res.render("game", makePageData(req.session.user, game)); + return res.render('game', makePageData(req.session.user, game)); } - return res.redirect("/games"); + return res.redirect('/games'); } diff --git a/controllers/games/root.js b/controllers/games/root.js index 4a4e80d..8b6fc22 100644 --- a/controllers/games/root.js +++ b/controllers/games/root.js @@ -1,17 +1,17 @@ -import { validationResult } from "express-validator"; +import { validationResult } from 'express-validator'; -import { getUserByUsername } from "../../database/users.js"; -import { listGames, newGame } from "../../database/games.js"; -import { emptyBoard, Bag } from "../../utils/board.js"; +import { getUserByUsername } from '../../database/users.js'; +import { listGames, newGame } from '../../database/games.js'; +import { emptyBoard, Bag } from '../../utils/board.js'; function makePageData(user) { return { - title: "Parties", + title: 'Parties', user: user, games: listGames(user.id), formdata: { - name: "", - username: "", + name: '', + username: '', }, errors: {}, }; @@ -20,7 +20,7 @@ function makePageData(user) { export function root_get(req, res) { let page = makePageData(req.session.user); page.games.forEach(g => g.data = JSON.parse(g.data)); - return res.render("games", page); + return res.render('games', page); } function makeNewGameData(name, player1, player2) { @@ -54,11 +54,11 @@ export function root_post(req, res) { if (gameId) { return res.redirect(302, `/games/${gameId}`); } else { - page.errors.mismatch = "Erreur du serveur: la création de partie a échoué"; + page.errors.mismatch = 'Erreur du serveur: la création de partie a échoué'; } } else { - page.errors.username = { msg: "L'identifiant n'existe pas." }; + page.errors.username = { msg: 'L\'identifiant n\'existe pas.' }; } } - return res.render("games", page); + return res.render('games', page); } diff --git a/controllers/root/login.js b/controllers/root/login.js index ac6a471..431f7f9 100644 --- a/controllers/root/login.js +++ b/controllers/root/login.js @@ -1,14 +1,14 @@ -import { validationResult } from "express-validator"; +import { validationResult } from 'express-validator'; -import { login } from "../../database/users.js"; +import { login } from '../../database/users.js'; function makePageData(user) { return { - title: "Connexion", + title: 'Connexion', user: user, data: { - username: "", - password: "", + username: '', + password: '', }, errors: {}, }; @@ -16,14 +16,14 @@ function makePageData(user) { export function login_get(req, res) { if (req.session.user !== undefined) { - return res.redirect(302, "/games"); + return res.redirect(302, '/games'); } - return res.render("login", makePageData(req.session.user)); + return res.render('login', makePageData(req.session.user)); } export async function login_post(req, res) { if (req.session.user !== undefined) { - return res.redirect(302, "/games"); + return res.redirect(302, '/games'); } let page = makePageData(req.session.user); page.data = req.body; @@ -33,11 +33,11 @@ export async function login_post(req, res) { if (user !== null) { req.session.user = user; } else { - page.errors.mismatch = "L'identifiant et le mot de passe ne correspondent pas, ou l'identifiant n'existe pas."; + page.errors.mismatch = 'L\'identifiant et le mot de passe ne correspondent pas, ou l\'identifiant n\'existe pas.'; } } if (Object.keys(page.errors).length === 0) { - return res.redirect(302, "/games"); + return res.redirect(302, '/games'); } - return res.render("login", page); + return res.render('login', page); } diff --git a/controllers/root/logout.js b/controllers/root/logout.js index 078df9a..d8b1b75 100644 --- a/controllers/root/logout.js +++ b/controllers/root/logout.js @@ -1,7 +1,7 @@ export function logout_get(req, res) { if (req.session.user !== undefined) { - res.clearCookie("JDMSessionId"); + res.clearCookie('JDMSessionId'); req.session.destroy(); } - return res.redirect(302, "/"); + return res.redirect(302, '/'); } diff --git a/controllers/root/root.js b/controllers/root/root.js index 062edf4..6349983 100644 --- a/controllers/root/root.js +++ b/controllers/root/root.js @@ -1,6 +1,6 @@ export function root_get(req, res) { if (req.session.user !== undefined) { - return res.redirect(302, "/games"); + return res.redirect(302, '/games'); } - return res.redirect(302, "/login"); + return res.redirect(302, '/login'); } |