diff --git a/public/index.html b/public/index.html index 4de37ea..ef2741d 100644 --- a/public/index.html +++ b/public/index.html @@ -35,10 +35,6 @@ -
⚠ En cas d'oubli du mot de passe, aucune récupération n'est possible.
diff --git a/public/src/api.js b/public/src/api.js index d39d39f..b7e7dec 100644 --- a/public/src/api.js +++ b/public/src/api.js @@ -42,11 +42,11 @@ export async function apiLogin(username, password) { }); } -export async function apiRegister(username, email, password, team) { +export async function apiRegister(username, password, team) { return fetch("/api/auth/register", { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ username, email, password, team }), + body: JSON.stringify({ username, password, team }), }); } diff --git a/public/src/auth.js b/public/src/auth.js index abafd30..8b531e6 100644 --- a/public/src/auth.js +++ b/public/src/auth.js @@ -12,7 +12,6 @@ const loginUsernameEl = document.getElementById("loginUsername"); const loginPasswordEl = document.getElementById("loginPassword"); const loginErrorEl = document.getElementById("loginError"); const regUsernameEl = document.getElementById("regUsername"); -const regEmailEl = document.getElementById("regEmail"); const regPasswordEl = document.getElementById("regPassword"); const registerErrorEl = document.getElementById("registerError"); const regCountBlueEl = document.getElementById("regCountBlue"); @@ -126,12 +125,11 @@ registerForm.addEventListener("submit", async (e) => { e.preventDefault(); clearError(registerErrorEl); const username = regUsernameEl.value.trim(); - const email = regEmailEl.value.trim(); const password = regPasswordEl.value; const teamInput = registerForm.querySelector('input[name="regTeam"]:checked'); if (!teamInput) { showError(registerErrorEl, "Please choose a team."); return; } try { - const res = await apiRegister(username, email, password, teamInput.value); + const res = await apiRegister(username, password, teamInput.value); const data = await res.json(); if (!res.ok) { const msgs = { diff --git a/public/style.css b/public/style.css index 1786205..7f3c34d 100644 --- a/public/style.css +++ b/public/style.css @@ -182,6 +182,14 @@ body { display: none; } +.authNotice { + margin: 0; + font-size: 11px; + color: rgba(255, 193, 113, 0.85); + text-align: center; + opacity: 0.8; +} + .authSubmit { margin-top: 4px; padding: 12px; diff --git a/server/db/usersDb.js b/server/db/usersDb.js index 4e05b09..da4cad6 100644 --- a/server/db/usersDb.js +++ b/server/db/usersDb.js @@ -7,7 +7,6 @@ export async function initUsersSchema() { CREATE TABLE IF NOT EXISTS users ( id SERIAL PRIMARY KEY, username TEXT NOT NULL UNIQUE, - email TEXT NOT NULL UNIQUE, password_hash TEXT NOT NULL, team TEXT NOT NULL CHECK (team IN ('blue', 'red')), role TEXT NOT NULL DEFAULT 'user' CHECK (role IN ('user', 'admin')), @@ -18,19 +17,19 @@ export async function initUsersSchema() { // ── Queries ─────────────────────────────────────────────────────────────────── -export async function createUser(username, email, passwordHash, team) { +export async function createUser(username, passwordHash, team) { const { rows } = await usersPool.query( - `INSERT INTO users (username, email, password_hash, team) - VALUES ($1, $2, $3, $4) - RETURNING id, username, email, team, role`, - [username, email, passwordHash, team] + `INSERT INTO users (username, password_hash, team) + VALUES ($1, $2, $3) + RETURNING id, username, team, role`, + [username, passwordHash, team] ); return rows[0]; } export async function getUserByUsername(username) { const { rows } = await usersPool.query( - `SELECT id, username, email, team, role, password_hash FROM users WHERE username = $1`, + `SELECT id, username, team, role, password_hash FROM users WHERE username = $1`, [username] ); return rows[0] ?? null; @@ -38,7 +37,7 @@ export async function getUserByUsername(username) { export async function getUserById(id) { const { rows } = await usersPool.query( - `SELECT id, username, email, team, role FROM users WHERE id = $1`, + `SELECT id, username, team, role FROM users WHERE id = $1`, [id] ); return rows[0] ?? null; diff --git a/server/routes/auth.js b/server/routes/auth.js index 8eeda35..c417d82 100644 --- a/server/routes/auth.js +++ b/server/routes/auth.js @@ -16,8 +16,8 @@ function issueToken(user) { // POST /api/auth/register router.post("/register", async (req, res) => { - const { username, email, password, team } = req.body ?? {}; - if (!username || !email || !password || !team) { + const { username, password, team } = req.body ?? {}; + if (!username || !password || !team) { return res.status(400).json({ error: "missing_fields" }); } if (team !== "blue" && team !== "red") { @@ -31,7 +31,7 @@ router.post("/register", async (req, res) => { } try { const passwordHash = await bcrypt.hash(password, 12); - const user = await createUser(username.trim(), email.trim().toLowerCase(), passwordHash, team); + const user = await createUser(username.trim(), passwordHash, team); const token = issueToken(user); return res.status(201).json({ token, @@ -39,7 +39,6 @@ router.post("/register", async (req, res) => { }); } catch (e) { if (e.code === "23505") { - if (e.constraint?.includes("email")) return res.status(409).json({ error: "email_taken" }); return res.status(409).json({ error: "username_taken" }); } console.error(e);