Correction du demarrage apres la modal d'authentification
This commit is contained in:
@@ -140,26 +140,15 @@
|
|||||||
=> user.FindFirst("email")?.Value
|
=> user.FindFirst("email")?.Value
|
||||||
?? "Session active";
|
?? "Session active";
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
private async Task OpenLoginModal()
|
||||||
{
|
=> await OpenAuthModalAsync("Se connecter", LoginHref);
|
||||||
if (!firstRender)
|
|
||||||
{
|
private async Task OpenRegisterModal()
|
||||||
return;
|
=> await OpenAuthModalAsync("Creer un compte", RegisterHref);
|
||||||
}
|
|
||||||
|
private async Task OpenAuthModalAsync(string title, string source)
|
||||||
_dotNetReference = DotNetObjectReference.Create(this);
|
|
||||||
await JS.InvokeVoidAsync("chesscubingAuthModal.registerListener", _dotNetReference);
|
|
||||||
_listenerRegistered = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OpenLoginModal()
|
|
||||||
=> OpenAuthModal("Se connecter", LoginHref);
|
|
||||||
|
|
||||||
private void OpenRegisterModal()
|
|
||||||
=> OpenAuthModal("Creer un compte", RegisterHref);
|
|
||||||
|
|
||||||
private void OpenAuthModal(string title, string source)
|
|
||||||
{
|
{
|
||||||
|
await EnsureAuthListenerAsync();
|
||||||
AuthModalTitle = title;
|
AuthModalTitle = title;
|
||||||
AuthModalSource = source;
|
AuthModalSource = source;
|
||||||
ShowAuthModal = true;
|
ShowAuthModal = true;
|
||||||
@@ -171,6 +160,27 @@
|
|||||||
AuthModalSource = null;
|
AuthModalSource = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task EnsureAuthListenerAsync()
|
||||||
|
{
|
||||||
|
if (_listenerRegistered)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_dotNetReference ??= DotNetObjectReference.Create(this);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await JS.InvokeVoidAsync("chesscubingAuthModal.registerListener", _dotNetReference);
|
||||||
|
_listenerRegistered = true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Si le navigateur garde encore un ancien script en cache,
|
||||||
|
// on laisse l'application fonctionner et la modal reste utilisable sans auto-fermeture.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[JSInvokable]
|
[JSInvokable]
|
||||||
public Task HandleAuthModalMessage(string status)
|
public Task HandleAuthModalMessage(string status)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -66,8 +66,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
await Task.Delay(700);
|
await Task.Delay(700);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
await JS.InvokeVoidAsync("chesscubingAuthModal.notifyParent", status);
|
await JS.InvokeVoidAsync("chesscubingAuthModal.notifyParent", status);
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static string NormalizeReturnUrl(string? returnUrl)
|
private static string NormalizeReturnUrl(string? returnUrl)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user