- Moves authentication back to a /Authenticate page route - Flatten the namespaces of page components - Implement top-level layouts as windows - Move handling of redirecting to /Authenticate with component inside of an AuthenticatedLayout - Use individiual injected services instead of SDK.Client - Wipe out tokens on logout - Process logout even if server can't be reached
62 lines
No EOL
1.9 KiB
Text
62 lines
No EOL
1.9 KiB
Text
@using LANCommander.SDK.Services
|
|
@namespace LANCommander.Launcher.UI
|
|
@inject IMessageService MessageService
|
|
@inject IConnectionClient ConnectionClient
|
|
|
|
<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 (_stage == AuthenticationStage.SelectServer)
|
|
{
|
|
<ServerSelector OnSelected="ServerSelected" Connecting="_connecting" />
|
|
}
|
|
else if (_stage == AuthenticationStage.Login)
|
|
{
|
|
<LoginForm ServerAddress="@ConnectionClient.GetServerAddress()" OnBack="() => _stage = AuthenticationStage.SelectServer" OnRegister="() => _stage = AuthenticationStage.Register" />
|
|
}
|
|
else if (_stage == AuthenticationStage.Register)
|
|
{
|
|
<RegistrationForm ServerAddress="@ConnectionClient.GetServerAddress()" OnBack="() => _stage = AuthenticationStage.Login" />
|
|
}
|
|
</div>
|
|
</Content>
|
|
</Layout>
|
|
|
|
@code {
|
|
bool _connecting { get; set; } = false;
|
|
AuthenticationStage _stage = AuthenticationStage.None;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await base.OnInitializedAsync();
|
|
|
|
if (ConnectionClient.HasServerAddress())
|
|
_stage = AuthenticationStage.Login;
|
|
else
|
|
_stage = AuthenticationStage.SelectServer;
|
|
}
|
|
|
|
async Task ServerSelected(Uri serverAddress)
|
|
{
|
|
try
|
|
{
|
|
_connecting = true;
|
|
|
|
await ConnectionClient.UpdateServerAddressAsync(serverAddress);
|
|
|
|
_stage = AuthenticationStage.Login;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageService.Error(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
_connecting = false;
|
|
}
|
|
}
|
|
} |