From c8c3ba2253dbb27801d386ff0395e294bc762442 Mon Sep 17 00:00:00 2001 From: Christophe Date: Mon, 13 Apr 2026 22:58:24 +0200 Subject: [PATCH] Correction du flux d'inscription Keycloak --- ChessCubing.App/Pages/Authentication.razor | 48 +++++++++++++++++++++- README.md | 1 + 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/ChessCubing.App/Pages/Authentication.razor b/ChessCubing.App/Pages/Authentication.razor index bb9535e..978ce4a 100644 --- a/ChessCubing.App/Pages/Authentication.razor +++ b/ChessCubing.App/Pages/Authentication.razor @@ -1,13 +1,59 @@ @page "/authentication/{action}" +@inject NavigationManager Navigation

Authentification

- + @if (IsRegisterAction) + { +
+ Redirection vers la creation de compte... +

L'inscription se poursuit dans Keycloak, puis vous reviendrez automatiquement dans l'application.

+
+ } + else + { + + }
@code { [Parameter] public string? Action { get; set; } + + [SupplyParameterFromQuery(Name = "returnUrl")] + public string? ReturnUrl { get; set; } + + private bool IsRegisterAction + => string.Equals(Action, RemoteAuthenticationActions.Register, StringComparison.OrdinalIgnoreCase); + + protected override void OnParametersSet() + { + if (!IsRegisterAction) + { + return; + } + + var request = new InteractiveRequestOptions + { + Interaction = InteractionType.SignIn, + ReturnUrl = NormalizeReturnUrl(ReturnUrl) + }; + + request.TryAddAdditionalParameter("prompt", "create"); + Navigation.NavigateToLogin("authentication/login", request); + } + + private static string NormalizeReturnUrl(string? returnUrl) + { + if (string.IsNullOrWhiteSpace(returnUrl)) + { + return "/"; + } + + return returnUrl.StartsWith("/", StringComparison.Ordinal) + ? returnUrl + : $"/{returnUrl}"; + } } diff --git a/README.md b/README.md index 320ca5d..05090fc 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ L'application embarque maintenant une authentification OpenID Connect basee sur - toutes les pages du site restent accessibles sans connexion - la page d'accueil et la page reglement affichent l'etat de session courant - la page d'accueil propose directement des actions `Se connecter` et `Creer un compte` +- l'action `Creer un compte` ouvre le parcours d'inscription natif de Keycloak - les roles Keycloak du realm sont exposes dans l'application - l'etat du match est isole par utilisateur dans le navigateur grace a une cle de stockage derivee du compte connecte