9b124deeea
- Rename project from decp.info to colibre across all codebase - Update domain from https://decp.info to https://colibre.fr - Update GitHub repo references to ColinMaudry/colibre - Rename deployment files: decpinfo-backup.* → colibre-backup.* - Update project configuration and documentation - Rename project assets: decp.info.png → colibre.png - Update environment variables and constants (DOMAIN_NAME, TOKEN_PREFIX, GITHUB_REPO, etc.) - Update URLs in all pages, tests, and configuration files - Keep DECP acronym in text (unchanged per requirements) - Add rebrand note to README.md Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
76 lines
2.6 KiB
Python
76 lines
2.6 KiB
Python
import dash_bootstrap_components as dbc
|
|
from dash import dcc, html, register_page
|
|
|
|
from src.auth.tokens import validate_password_reset_token
|
|
|
|
NAME = "Réinitialiser le mot de passe"
|
|
|
|
register_page(
|
|
__name__,
|
|
path="/reinitialiser-mot-de-passe",
|
|
title="Nouveau mot de passe | colibre",
|
|
name=NAME,
|
|
description="Choisir un nouveau mot de passe.",
|
|
)
|
|
|
|
ERROR_MESSAGES = {
|
|
"invalid_token": "Lien invalide ou expiré. Demandez un nouveau lien de réinitialisation.",
|
|
"password_too_short": "Le mot de passe doit faire au moins 8 caractères.",
|
|
"password_mismatch": "Les mots de passe ne correspondent pas.",
|
|
}
|
|
|
|
|
|
def layout(token: str | None = None, error: str | None = None, **_):
|
|
if not token or validate_password_reset_token(token) is None:
|
|
return dbc.Container(
|
|
className="py-4",
|
|
style={"maxWidth": "500px"},
|
|
children=[
|
|
html.H2("Lien invalide"),
|
|
dbc.Alert(ERROR_MESSAGES["invalid_token"], color="danger"),
|
|
dcc.Link("Demander un nouveau lien", href="/mot-de-passe-oublie"),
|
|
],
|
|
)
|
|
|
|
alerts = []
|
|
if error and error in ERROR_MESSAGES:
|
|
alerts.append(dbc.Alert(ERROR_MESSAGES[error], color="danger"))
|
|
|
|
return dbc.Container(
|
|
className="py-4",
|
|
style={"maxWidth": "500px"},
|
|
children=[
|
|
html.H2("Choisir un nouveau mot de passe"),
|
|
*alerts,
|
|
html.Form(
|
|
method="POST",
|
|
action="/auth/reset-password",
|
|
children=[
|
|
dcc.Input(
|
|
type="hidden",
|
|
id={"type": "csrf-input", "index": "reset"},
|
|
name="csrf_token",
|
|
),
|
|
dcc.Input(type="hidden", name="token", value=token),
|
|
dbc.Label("Nouveau mot de passe (8 caractères minimum)"),
|
|
dbc.Input(
|
|
type="password",
|
|
name="password",
|
|
required=True,
|
|
minLength=8,
|
|
className="mb-3",
|
|
),
|
|
dbc.Label("Confirmer le nouveau mot de passe"),
|
|
dbc.Input(
|
|
type="password",
|
|
name="password_confirm",
|
|
required=True,
|
|
minLength=8,
|
|
className="mb-3",
|
|
),
|
|
dbc.Button("Valider", type="submit", color="primary"),
|
|
],
|
|
),
|
|
],
|
|
)
|