Forcer le flux interactif dans la modal d'authentification
This commit is contained in:
@@ -84,6 +84,8 @@
|
||||
|
||||
private string LoginHref => BuildAuthHref("login", EffectiveReturnUrl);
|
||||
private string RegisterHref => BuildAuthHref("register", EffectiveReturnUrl);
|
||||
private string LoginModalSrc => BuildAuthHref("login", EffectiveReturnUrl, embedded: true);
|
||||
private string RegisterModalSrc => BuildAuthHref("register", EffectiveReturnUrl, embedded: true);
|
||||
private string LogoutHref => BuildAuthHref("logout", "/");
|
||||
|
||||
private string CurrentPath
|
||||
@@ -120,8 +122,16 @@
|
||||
private bool IsCurrentPage(string[] paths)
|
||||
=> paths.Any(path => string.Equals(CurrentPath, path, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
private static string BuildAuthHref(string action, string returnUrl)
|
||||
=> $"authentication/{action}?returnUrl={Uri.EscapeDataString(returnUrl)}";
|
||||
private static string BuildAuthHref(string action, string returnUrl, bool embedded = false)
|
||||
{
|
||||
var query = $"returnUrl={Uri.EscapeDataString(returnUrl)}";
|
||||
if (embedded)
|
||||
{
|
||||
query += "&embedded=1";
|
||||
}
|
||||
|
||||
return $"authentication/{action}?{query}";
|
||||
}
|
||||
|
||||
private static string BuildDisplayName(ClaimsPrincipal user)
|
||||
=> user.Identity?.Name
|
||||
@@ -141,10 +151,10 @@
|
||||
}
|
||||
|
||||
private async Task OpenLoginModal()
|
||||
=> await OpenAuthModalAsync("Se connecter", LoginHref);
|
||||
=> await OpenAuthModalAsync("Se connecter", LoginModalSrc);
|
||||
|
||||
private async Task OpenRegisterModal()
|
||||
=> await OpenAuthModalAsync("Creer un compte", RegisterHref);
|
||||
=> await OpenAuthModalAsync("Creer un compte", RegisterModalSrc);
|
||||
|
||||
private async Task OpenAuthModalAsync(string title, string source)
|
||||
{
|
||||
|
||||
@@ -5,11 +5,15 @@
|
||||
<main class="rules-shell">
|
||||
<section class="panel panel-wide cta-panel" style="margin-top: 2rem;">
|
||||
<p class="eyebrow">Authentification</p>
|
||||
@if (IsRegisterAction)
|
||||
@if (StartsInteractiveFlow)
|
||||
{
|
||||
<div>
|
||||
<strong>Redirection vers la creation de compte...</strong>
|
||||
<p>L'inscription se poursuit dans Keycloak, puis vous reviendrez automatiquement dans l'application.</p>
|
||||
<strong>@(IsRegisterAction ? "Ouverture de la creation de compte..." : "Ouverture de la connexion...")</strong>
|
||||
<p>
|
||||
@(IsRegisterAction
|
||||
? "Le formulaire Keycloak s'ouvre dans cette fenetre integree."
|
||||
: "Le formulaire de connexion Keycloak s'ouvre dans cette fenetre integree.")
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
@@ -26,12 +30,25 @@
|
||||
[SupplyParameterFromQuery(Name = "returnUrl")]
|
||||
public string? ReturnUrl { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery(Name = "embedded")]
|
||||
public string? Embedded { get; set; }
|
||||
|
||||
private bool IsRegisterAction
|
||||
=> string.Equals(Action, RemoteAuthenticationActions.Register, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
private bool IsLoginAction
|
||||
=> string.Equals(Action, RemoteAuthenticationActions.LogIn, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
private bool IsEmbeddedFlow
|
||||
=> string.Equals(Embedded, "1", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(Embedded, "true", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
private bool StartsInteractiveFlow
|
||||
=> IsEmbeddedFlow && (IsLoginAction || IsRegisterAction);
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (!IsRegisterAction)
|
||||
if (!StartsInteractiveFlow)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -42,7 +59,11 @@
|
||||
ReturnUrl = NormalizeReturnUrl(ReturnUrl)
|
||||
};
|
||||
|
||||
if (IsRegisterAction)
|
||||
{
|
||||
request.TryAddAdditionalParameter("prompt", "create");
|
||||
}
|
||||
|
||||
Navigation.NavigateToLogin("authentication/login", request);
|
||||
}
|
||||
|
||||
@@ -60,13 +81,11 @@
|
||||
_ => null,
|
||||
};
|
||||
|
||||
if (status is null)
|
||||
if (status is null || !IsEmbeddedFlow)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await Task.Delay(700);
|
||||
|
||||
try
|
||||
{
|
||||
await JS.InvokeVoidAsync("chesscubingAuthModal.notifyParent", status);
|
||||
|
||||
Reference in New Issue
Block a user