Comptes adherents, boite de reception admin, edition profil

Comptes de connexion adherent
- addMember cree desormais un compte users (role member, lie a la fiche)
  avec un mot de passe temporaire genere
- Le mdp temporaire s'affiche sur la fiche admin (/backend/adherents/[id])
  jusqu'a la 1ere connexion ; bouton "Reinitialiser le mot de passe"
- 1ere connexion : changement de mot de passe force (must_change_password)
  via /backend/changer-mot-de-passe, redirection geree dans authorized()
- users += must_change_password, temp_password (migration 0003)

Boite de reception admin (consultation)
- Page /backend/demandes : demandes d'adhesion + messages de contact
  avec statuts (approuvee/rejetee, lu/archive)
- Lien sidebar + badge (nouveaux), carte tableau de bord cliquable

Espace adherent
- L'adherent peut editer sa propre fiche (updateOwnProfile) : infos,
  description, horaires, tags, image d'entete + logo
- Statut/categorie/mise a l'honneur restent reserves au staff

Promotions : moderation deja en place, inchangee.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Opus 4.8 committed 2026-06-27 09:47:05 +02:00
1 parent b4d94f2115
commit 119ad4665a
16 files changed
+1146 -25

No files matched your search

+15 -2
View File
@@ -1,4 +1,7 @@
import type { NextAuthConfig } from "next-auth";
import { NextResponse } from "next/server";
const CHANGE_PW_PATH = "/backend/changer-mot-de-passe";
/**
* Edge-safe Auth.js configuration (no database / bcrypt imports here).
@@ -18,6 +21,8 @@ export const authConfig = {
token.uid = (user as { id?: string }).id ?? token.sub;
token.role = (user as { role?: string }).role;
token.memberId = (user as { memberId?: number | null }).memberId ?? null;
token.mustChangePassword =
(user as { mustChangePassword?: boolean }).mustChangePassword ?? false;
}
return token;
},
@@ -30,14 +35,22 @@ export const authConfig = {
| "editor"
| "member";
session.user.memberId = (token.memberId as number | null) ?? null;
session.user.mustChangePassword = Boolean(token.mustChangePassword);
}
return session;
},
authorized({ auth, request }) {
const isLoggedIn = !!auth?.user;
const { pathname } = request.nextUrl;
const { pathname, origin } = request.nextUrl;
if (pathname.startsWith("/backend")) {
return isLoggedIn;
if (!isLoggedIn) return false;
const mustChange = Boolean(
(auth?.user as { mustChangePassword?: boolean } | undefined)?.mustChangePassword,
);
if (mustChange && pathname !== CHANGE_PW_PATH) {
return NextResponse.redirect(new URL(CHANGE_PW_PATH, origin));
}
return true;
}
return true;
},