
Adjustment to ActionLink component to support custom button classes. Adjustment of all button styles inside of the project to swap to either btn-danger for delete operations or btn-secondary for cancel operations for consistency.
50 lines
1.8 KiB
Plaintext
50 lines
1.8 KiB
Plaintext
@using Microsoft.AspNetCore.Components.Routing
|
|
@using Oqtane.Shared
|
|
@using Oqtane.Modules
|
|
@using Microsoft.JSInterop
|
|
@using Oqtane.Models
|
|
@using Oqtane.Services
|
|
@using Oqtane.Client.Modules.Controls
|
|
@inherits ModuleBase
|
|
@inject IUriHelper UriHelper
|
|
@inject IJSRuntime jsRuntime
|
|
@inject IUserService UserService
|
|
|
|
<div class="container">
|
|
@((MarkupString)Message)
|
|
<div class="form-group">
|
|
<label for="Username" class="control-label">Username: </label>
|
|
<input type="text" name="Username" class="form-control" placeholder="Username" bind="@Username" />
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="Password" class="control-label">Password: </label>
|
|
<input type="password" name="Password" class="form-control" placeholder="Password" bind="@Password" />
|
|
</div>
|
|
<button type="button" class="btn btn-primary" onclick="@Login">Login</button>
|
|
<NavLink class="btn btn-secondary" href="/">Cancel</NavLink>
|
|
</div>
|
|
|
|
@functions {
|
|
public override SecurityAccessLevelEnum SecurityAccessLevel { get { return SecurityAccessLevelEnum.Anonymous; } }
|
|
|
|
public string Message { get; set; } = "<div class=\"alert alert-info\" role=\"alert\">Use host/host For Demo Access</div>";
|
|
public string Username { get; set; } = "";
|
|
public string Password { get; set; } = "";
|
|
|
|
private async Task Login()
|
|
{
|
|
List<User> users = await UserService.GetUsersAsync();
|
|
User user = users.Where(item => item.Username == Username).FirstOrDefault();
|
|
if (user != null)
|
|
{
|
|
var interop = new Interop(jsRuntime);
|
|
await interop.SetCookie("user", user.UserId.ToString(), 7);
|
|
UriHelper.NavigateTo(PageState.Alias, true);
|
|
}
|
|
else
|
|
{
|
|
Message = "<div class=\"alert alert-danger\" role=\"alert\">User Does Not Exist</div>";
|
|
}
|
|
}
|
|
}
|