Adds localization across the launcher and includes English, German, Spanish, French, Italian, Japanese, Korean, Dutch, Portuguese, Ukranian, and Chinese. These localizations were generated by Claude 3.5 and need to be reviewed by a human for accuracy.
54 lines
No EOL
1.6 KiB
Text
54 lines
No EOL
1.6 KiB
Text
@using LANCommander.SDK.Models
|
|
@using Newtonsoft.Json
|
|
@using Photino.NET
|
|
@inject SDK.Client Client
|
|
@inject IJSRuntime JSRuntime
|
|
@inject IMessageService MessageService
|
|
@inject ILogger<AuthenticationProviderDialog> Logger
|
|
@inject LocalizationService LocalizationService
|
|
|
|
@code {
|
|
[Parameter] public EventCallback<AuthToken> OnTokenReceived { get; set; }
|
|
|
|
string AuthenticationProviderLoginUrl;
|
|
|
|
PhotinoWindow Window;
|
|
|
|
public async Task Open(string baseUrl, AuthenticationProvider authenticationProvider)
|
|
{
|
|
await Client.ChangeServerAddressAsync(baseUrl);
|
|
|
|
AuthenticationProviderLoginUrl = Client.GetAuthenticationProviderLoginUrl(authenticationProvider.Slug);
|
|
|
|
Window = new PhotinoWindow()
|
|
.SetTitle(LocalizationService.GetString("SignInUsingProvider", authenticationProvider.Name))
|
|
.Load(AuthenticationProviderLoginUrl)
|
|
.SetContextMenuEnabled(false);
|
|
|
|
Window.RegisterWebMessageReceivedHandler(MessageHandler);
|
|
|
|
Window.WaitForClose();
|
|
}
|
|
|
|
async void MessageHandler(object? sender, string message)
|
|
{
|
|
try
|
|
{
|
|
var token = JsonConvert.DeserializeObject<AuthToken>(message);
|
|
|
|
await InvokeAsync(() =>
|
|
{
|
|
OnTokenReceived.InvokeAsync(token);
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.LogError(ex, "Could not process login");
|
|
MessageService.Error(LocalizationService.GetString("CouldNotProcessLogin"));
|
|
}
|
|
finally
|
|
{
|
|
Window.Close();
|
|
}
|
|
}
|
|
} |