summaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
Diffstat (limited to 'routes')
-rw-r--r--routes/games.js5
-rw-r--r--routes/root.js10
2 files changed, 5 insertions, 10 deletions
diff --git a/routes/games.js b/routes/games.js
index 67d105d..3a27cdb 100644
--- a/routes/games.js
+++ b/routes/games.js
@@ -1,15 +1,18 @@
import express from "express";
import { gameId_get } from "../controllers/games/gameId.js";
-import { root_get } from "../controllers/games/root.js";
+import { root_get, root_post } from "../controllers/games/root.js";
+import bodyParser from "../middlewares/formParser.js";
import requireAuth from "../middlewares/requireAuth.js";
import session from "../middlewares/sessions.js";
+import { checkName, checkUsername } from "../utils/checks.js";
const router = express.Router();
router.use(session);
router.use(requireAuth);
router.get("/", root_get);
+router.post("/", [bodyParser, checkName, checkUsername], root_post);
router.get("/:gameId(\\d+)", gameId_get);
export default router;
diff --git a/routes/root.js b/routes/root.js
index c41f3e1..863b99d 100644
--- a/routes/root.js
+++ b/routes/root.js
@@ -1,23 +1,15 @@
import express from "express";
-import { check } from "express-validator";
import { login_get, login_post } from "../controllers/root/login.js";
import { logout_get } from "../controllers/root/logout.js";
import { root_get } from "../controllers/root/root.js";
import bodyParser from "../middlewares/formParser.js";
import session from "../middlewares/sessions.js";
+import { checkUsername, checkPassword } from "../utils/checks.js";
const router = express.Router();
router.use(session);
-const checkUsername = check("username")
- .trim()
- .matches(/^[a-z][-a-z0-9_]+$/i)
- .withMessage("Un identifiant d'au moins deux charactères est requis.");
-const checkPassword = check("password")
- .isStrongPassword()
- .withMessage("Veuillez utiliser un mot de passe d'au moins 8 caractères contenant au moins une minuscule, majuscule, chiffre et charactère spécial.");
-
router.get("/", root_get);
router.get("/login", login_get);
router.post("/login", [bodyParser, checkUsername, checkPassword], login_post);