Improved page reload efficiency, refactored NavigateUrl and EditUrl helpers, added antiforgery token and returnurl to Logout scenario, fixed PageModule service call api url, modified rendering engine to allow for component differentiation
This commit is contained in:
@ -26,7 +26,12 @@
|
||||
@code {
|
||||
private void LoginUser()
|
||||
{
|
||||
UriHelper.NavigateTo(NavigateUrl("login?returnurl=" + PageState.Page.Path));
|
||||
string returnurl = PageState.Alias.Path;
|
||||
if (PageState.Page.Path != "/")
|
||||
{
|
||||
returnurl += "/" + PageState.Page.Path;
|
||||
}
|
||||
UriHelper.NavigateTo("login?returnurl=" + returnurl);
|
||||
}
|
||||
|
||||
private async Task LogoutUser()
|
||||
@ -38,13 +43,16 @@
|
||||
{
|
||||
// server-side Blazor
|
||||
var interop = new Interop(jsRuntime);
|
||||
await interop.SubmitForm("/logout/", "");
|
||||
string antiforgerytoken = await interop.GetElementByName("__RequestVerificationToken");
|
||||
var fields = new { __RequestVerificationToken = antiforgerytoken, returnurl = (PageState.Alias.Path + "/" + PageState.Page.Path) };
|
||||
await interop.SubmitForm("/logout/", fields);
|
||||
}
|
||||
else
|
||||
{
|
||||
// client-side Blazor
|
||||
authstateprovider.NotifyAuthenticationChanged();
|
||||
UriHelper.NavigateTo(NavigateUrl("login", true));
|
||||
PageState.Reload = Constants.ReloadPage;
|
||||
UriHelper.NavigateTo(NavigateUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user