Initial commit
This commit is contained in:
41
Oqtane.Client/Skins/Controls/Login.razor
Normal file
41
Oqtane.Client/Skins/Controls/Login.razor
Normal file
@ -0,0 +1,41 @@
|
||||
@using Oqtane.Skins
|
||||
@using Oqtane.Shared
|
||||
@using Microsoft.JSInterop
|
||||
@inherits SkinObjectBase
|
||||
@inject IUriHelper UriHelper
|
||||
@inject IJSRuntime jsRuntime
|
||||
|
||||
<button type="button" class="btn btn-primary" onclick="@Click">@name</button>
|
||||
|
||||
@functions {
|
||||
string name = "";
|
||||
|
||||
protected override async Task OnInitAsync()
|
||||
{
|
||||
var interop = new Interop(jsRuntime);
|
||||
string user = await interop.GetCookie("user");
|
||||
|
||||
if (user == "")
|
||||
{
|
||||
name = "Login";
|
||||
}
|
||||
else
|
||||
{
|
||||
name = "Logout";
|
||||
}
|
||||
}
|
||||
|
||||
private async Task Click()
|
||||
{
|
||||
if (name == "Login")
|
||||
{
|
||||
UriHelper.NavigateTo(PageState.Alias + "login");
|
||||
}
|
||||
else
|
||||
{
|
||||
var interop = new Interop(jsRuntime);
|
||||
await interop.SetCookie("user", "", 7);
|
||||
UriHelper.NavigateTo(PageState.Alias, true);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user