Correction du flux d'inscription Keycloak
This commit is contained in:
@@ -1,13 +1,59 @@
|
||||
@page "/authentication/{action}"
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
<main class="rules-shell">
|
||||
<section class="panel panel-wide cta-panel" style="margin-top: 2rem;">
|
||||
<p class="eyebrow">Authentification</p>
|
||||
<RemoteAuthenticatorView Action="@Action" />
|
||||
@if (IsRegisterAction)
|
||||
{
|
||||
<div>
|
||||
<strong>Redirection vers la creation de compte...</strong>
|
||||
<p>L'inscription se poursuit dans Keycloak, puis vous reviendrez automatiquement dans l'application.</p>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<RemoteAuthenticatorView Action="@Action" />
|
||||
}
|
||||
</section>
|
||||
</main>
|
||||
|
||||
@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}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user