1
0
Kevin Matsubara b65d998b01 Add policy authorization based on claim for admin role.
Note that this redirects to the login page, it should actually display an Access Denied message.
2025-04-18 17:53:20 +02:00

62 lines
1.2 KiB
Plaintext

@page "/servername"
@using Microsoft.AspNetCore.Authorization
@using ServerManagement.StateStore
@inject NavigationManager NavigationManager
@inject ContainerStorage containerStorage
@attribute [Authorize]
<h3>Server Name</h3>
<br/>
@if (!string.IsNullOrWhiteSpace(errorMessage))
{
<div class="alert alert-danger">
@errorMessage
</div>
}
@if (server != null)
{
<FieldComponent Label="Server name">
<Control>
<input type="text" @bind-value="server.Name" class="form-control"></input>
</Control>
</FieldComponent>
<br/>
<button type="button" class="btn btn-primary" @onclick="GoNext">Next</button>
}
@code {
private Server? server;
private string? errorMessage;
protected override void OnInitialized()
{
base.OnInitialized();
}
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
server = new Server();
StateHasChanged();
}
}
private void GoNext()
{
if (string.IsNullOrWhiteSpace(server?.Name))
{
this.errorMessage = "Server name is required.";
}
else
{
containerStorage.SetServer(server);
NavigationManager.NavigateTo($"/cityname");
}
}
}