Integrated AuthenticationStateProvider using .NET Core Identity

This commit is contained in:
Shaun Walker
2019-07-08 12:52:40 -04:00
parent 46821b8a10
commit 6cf1eb1c31
21 changed files with 565 additions and 137 deletions

View File

@ -1,35 +1,25 @@
@using Microsoft.AspNetCore.Components.Routing
@using Oqtane.Themes
@using Oqtane.Shared
@using Oqtane.Services;
@using Oqtane.Models;
@using Microsoft.JSInterop
@inject IJSRuntime jsRuntime
@using Oqtane.Themes
@inherits ThemeObjectBase
@inject IUriHelper UriHelper
<AuthorizeView>
<Authorizing>
<text>...</text>
</Authorizing>
<Authorized>
<button type="button" class="btn btn-primary" @onclick="@RegisterUser">@context.User.Identity.Name</button>
</Authorized>
<NotAuthorized>
<button type="button" class="btn btn-primary" @onclick="@RegisterUser">Register</button>
</NotAuthorized>
</AuthorizeView>
<NavLink class="btn btn-primary" href="@url">@name</NavLink>
@code {
string name = "";
string url = "";
protected override async Task OnInitAsync()
private void RegisterUser()
{
var interop = new Interop(jsRuntime);
string userid = await interop.GetCookie("user");
if (userid == "")
{
name = "Register";
url = "register";
}
else
{
if (PageState.User != null)
{
name = PageState.User.DisplayName;
}
}
UriHelper.NavigateTo(NavigateUrl("register"));
}
}