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