Files
colibre/src/pages/connexion.py
T
Colin Maudry 9b124deeea refactor: rebrand decp.info to colibre #57
- 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>
2026-06-30 21:43:33 +02:00

99 lines
3.2 KiB
Python

import dash_bootstrap_components as dbc
from dash import dcc, html, register_page
NAME = "Connexion"
register_page(
__name__,
path="/connexion",
title="Connexion | colibre",
name=NAME,
description="Se connecter à colibre.",
)
ERROR_MESSAGES = {
"invalid_credentials": "Identifiants invalides.",
"email_not_verified": "Vérifiez d'abord votre adresse email (consultez votre boîte de réception).",
"oauth_cancelled": "Connexion LinkedIn annulée.",
"oauth_failed": "Échec de la connexion via LinkedIn. Réessayez.",
}
INFO_MESSAGES = {
"pending_verification": (
"Compte créé. Un email de vérification a été envoyé. "
"Cliquez sur le lien reçu avant de vous connecter."
),
"verified": "Adresse email vérifiée. Vous pouvez maintenant vous connecter.",
"password_changed": "Mot de passe mis à jour. Connectez-vous avec le nouveau.",
}
def linkedin_button():
return html.A(
"Connexion avec LinkedIn",
href="/auth/linkedin",
className="btn w-100 mb-2",
style={"backgroundColor": "rgb(10, 102, 194)", "color": "white"},
)
def layout(error: str | None = None, email: str | None = None, **kwargs):
alerts = []
if error and error in ERROR_MESSAGES:
alerts.append(dbc.Alert(ERROR_MESSAGES[error], color="danger"))
for flag, msg in INFO_MESSAGES.items():
if kwargs.get(flag) == "1":
alerts.append(dbc.Alert(msg, color="info"))
next_url = kwargs.get("next", "")
return dbc.Container(
className="py-4",
style={"maxWidth": "500px"},
children=[
html.H2("Connexion"),
*alerts,
html.Form(
method="POST",
action="/auth/login",
children=[
dcc.Input(
type="hidden",
id={"type": "csrf-input", "index": "login"},
name="csrf_token",
),
dcc.Input(type="hidden", name="next", value=next_url),
dbc.Label("Adresse email"),
dbc.Input(
type="email",
name="email",
required=True,
value=email or "",
className="mb-3",
),
dbc.Label("Mot de passe"),
dbc.Input(
type="password",
name="password",
required=True,
className="mb-3",
),
dbc.Button("Se connecter", type="submit", color="primary"),
],
),
dcc.Link(
"Mot de passe oublié ?",
href="/mot-de-passe-oublie",
className="small d-block mt-2",
),
html.Div("ou", className="text-center text-muted my-2"),
linkedin_button(),
html.Div("ou", className="text-center text-muted my-2"),
html.A(
"Créer un compte avec mon adresse email",
href="/inscription",
className="btn btn-primary w-100",
),
],
)