@page "/authentication/{action}" @inject NavigationManager Navigation @inject IJSRuntime JS

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); } protected override async Task OnAfterRenderAsync(bool firstRender) { if (!firstRender) { return; } var status = Action switch { RemoteAuthenticationActions.LogInCallback => "login-succeeded", RemoteAuthenticationActions.LogOutCallback => "logout-succeeded", _ => null, }; if (status is null) { return; } await Task.Delay(700); try { await JS.InvokeVoidAsync("chesscubingAuthModal.notifyParent", status); } catch { } } private static string NormalizeReturnUrl(string? returnUrl) { if (string.IsNullOrWhiteSpace(returnUrl)) { return "/"; } return returnUrl.StartsWith("/", StringComparison.Ordinal) ? returnUrl : $"/{returnUrl}"; } }