73 lines
No EOL
2.2 KiB
Text
73 lines
No EOL
2.2 KiB
Text
@using System.Security.Policy
|
|
@using BeaconLib
|
|
@using LANCommander.Launcher.Models
|
|
@using LANCommander.SDK
|
|
@using LANCommander.SDK.Models
|
|
@using LANCommander.Launcher.UI.Authenticate.Components
|
|
@inject ProfileService ProfileService
|
|
@inject NavigationManager NavigationManager
|
|
@inject SDK.Client Client
|
|
@inject IMessageService MessageService
|
|
@inject ILogger<System.Index> Logger
|
|
|
|
<CascadingValue Value="State">
|
|
<Layout Style="background-image: url('/assets/auth-background.jpg'); background-size: cover;">
|
|
<Content Class="authentication-form">
|
|
<div class="authentication-logo">
|
|
<img src="/assets/logo.svg" width="300" />
|
|
</div>
|
|
|
|
<div class="authentication-box">
|
|
@if (State.Stage == AuthenticationStage.SelectServer)
|
|
{
|
|
<ServerSelector OnSelected="ServerSelected" Connecting="_connecting" />
|
|
}
|
|
|
|
@if (State.Stage == AuthenticationStage.Login)
|
|
{
|
|
<LoginForm ServerAddress="@State.ServerAddress" OnBack="() => State.Stage = AuthenticationStage.SelectServer" OnRegister="() => State.Stage = AuthenticationStage.Register" />
|
|
}
|
|
|
|
@if (State.Stage == AuthenticationStage.Register)
|
|
{
|
|
<RegistrationForm ServerAddress="@State.ServerAddress" OnBack="() => State.Stage = AuthenticationStage.Login" />
|
|
}
|
|
</div>
|
|
</Content>
|
|
</Layout>
|
|
</CascadingValue>
|
|
|
|
@code {
|
|
AuthenticationFormState State { get; set; }
|
|
|
|
bool _connecting { get; set; } = false;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
State = new()
|
|
{
|
|
Stage = AuthenticationStage.SelectServer,
|
|
ServerAddress = String.Empty,
|
|
};
|
|
}
|
|
|
|
async Task ServerSelected(string serverAddress)
|
|
{
|
|
try
|
|
{
|
|
_connecting = true;
|
|
|
|
await Client.ChangeServerAddressAsync(serverAddress);
|
|
State.ServerAddress = Client.GetServerAddress();
|
|
State.Stage = AuthenticationStage.Login;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageService.Error(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
_connecting = false;
|
|
}
|
|
}
|
|
} |