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

68 lines
1.3 KiB
Plaintext

@page "/cityname"
@using Microsoft.AspNetCore.Authorization
@using ServerManagement.StateStore
@inject NavigationManager NavigationManager
@inject ContainerStorage containerStorage
@attribute [Authorize]
<h3>City Name</h3>
<br/>
@if (!string.IsNullOrWhiteSpace(errorMessage))
{
<div class="alert alert-danger">
@errorMessage
</div>
}
@if (server != null)
{
<FieldComponent Label="City name">
<Control>
<input type="text" @bind-value="server.City" 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;
[SupplyParameterFromQuery]
private string? ServerName { get; set; }
protected override void OnInitialized()
{
base.OnInitialized();
}
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
this.server = containerStorage.GetServer();
StateHasChanged();
}
}
private void GoNext()
{
if (server != null)
{
if (string.IsNullOrWhiteSpace(server.City))
{
this.errorMessage = "City name is required.";
}
else
{
containerStorage.SetServer(server);
NavigationManager.NavigateTo($"/serverstatus");
}
}
}
}