feat(auth): bouton Connexion avec LinkedIn sur connexion/inscription (#88)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,8 @@ register_page(
|
|||||||
ERROR_MESSAGES = {
|
ERROR_MESSAGES = {
|
||||||
"invalid_credentials": "Identifiants invalides.",
|
"invalid_credentials": "Identifiants invalides.",
|
||||||
"email_not_verified": "Vérifiez d'abord votre adresse email (consultez votre boîte de réception).",
|
"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 = {
|
INFO_MESSAGES = {
|
||||||
@@ -26,6 +28,15 @@ INFO_MESSAGES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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):
|
def layout(error: str | None = None, email: str | None = None, **kwargs):
|
||||||
alerts = []
|
alerts = []
|
||||||
if error and error in ERROR_MESSAGES:
|
if error and error in ERROR_MESSAGES:
|
||||||
@@ -70,6 +81,8 @@ def layout(error: str | None = None, email: str | None = None, **kwargs):
|
|||||||
dbc.Button("Se connecter", type="submit", color="primary"),
|
dbc.Button("Se connecter", type="submit", color="primary"),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
html.Div("ou", className="text-center text-muted my-2"),
|
||||||
|
linkedin_button(),
|
||||||
html.Hr(),
|
html.Hr(),
|
||||||
html.Div(
|
html.Div(
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import dash_bootstrap_components as dbc
|
import dash_bootstrap_components as dbc
|
||||||
from dash import dcc, html, register_page
|
from dash import dcc, html, register_page
|
||||||
|
|
||||||
|
from src.pages.connexion import linkedin_button
|
||||||
|
|
||||||
NAME = "Inscription"
|
NAME = "Inscription"
|
||||||
|
|
||||||
register_page(
|
register_page(
|
||||||
@@ -67,6 +69,8 @@ def layout(error: str | None = None, email: str | None = None, **_):
|
|||||||
dbc.Button("Créer le compte", type="submit", color="primary"),
|
dbc.Button("Créer le compte", type="submit", color="primary"),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
html.Div("ou", className="text-center text-muted my-2"),
|
||||||
|
linkedin_button(),
|
||||||
html.Hr(),
|
html.Hr(),
|
||||||
dcc.Link("Déjà un compte ? Se connecter", href="/connexion"),
|
dcc.Link("Déjà un compte ? Se connecter", href="/connexion"),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -72,3 +72,28 @@ def test_callback_user_cancelled_redirects(client, users_db_path):
|
|||||||
resp = client.get("/auth/linkedin/callback?error=user_cancelled_login")
|
resp = client.get("/auth/linkedin/callback?error=user_cancelled_login")
|
||||||
assert resp.status_code == 302
|
assert resp.status_code == 302
|
||||||
assert "error=oauth_cancelled" in resp.headers["Location"]
|
assert "error=oauth_cancelled" in resp.headers["Location"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_connexion_layout_has_linkedin_button():
|
||||||
|
import src.app # noqa: F401 - Initialize Dash app before importing pages
|
||||||
|
from src.pages.connexion import layout
|
||||||
|
|
||||||
|
html_str = str(layout())
|
||||||
|
assert "Connexion avec LinkedIn" in html_str
|
||||||
|
assert "/auth/linkedin" in html_str
|
||||||
|
|
||||||
|
|
||||||
|
def test_connexion_layout_shows_oauth_error():
|
||||||
|
import src.app # noqa: F401 - Initialize Dash app before importing pages
|
||||||
|
from src.pages.connexion import layout
|
||||||
|
|
||||||
|
assert "LinkedIn" in str(layout(error="oauth_failed"))
|
||||||
|
|
||||||
|
|
||||||
|
def test_inscription_layout_has_linkedin_button():
|
||||||
|
import src.app # noqa: F401 - Initialize Dash app before importing pages
|
||||||
|
from src.pages.inscription import layout
|
||||||
|
|
||||||
|
html_str = str(layout())
|
||||||
|
assert "Connexion avec LinkedIn" in html_str
|
||||||
|
assert "/auth/linkedin" in html_str
|
||||||
|
|||||||
Reference in New Issue
Block a user