diff --git a/WotBlitzStatisticsPro.Blazor/Messages/RedirectToWgLoginMessage.cs b/WotBlitzStatisticsPro.Blazor/Messages/RedirectToWgLoginMessage.cs new file mode 100644 index 0000000..0fc1a5a --- /dev/null +++ b/WotBlitzStatisticsPro.Blazor/Messages/RedirectToWgLoginMessage.cs @@ -0,0 +1,15 @@ +using MediatR; +using WotBlitzStatisticsPro.Blazor.GraphQl; + +namespace WotBlitzStatisticsPro.Blazor.Messages +{ + public class RedirectToWgLoginMessage: INotification + { + public RealmType Realm { get; } + + public RedirectToWgLoginMessage(RealmType realm) + { + Realm = realm; + } + } +} \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Blazor/Pages/WgLoginDialog.razor b/WotBlitzStatisticsPro.Blazor/Pages/WgLoginDialog.razor new file mode 100644 index 0000000..80c7ad5 --- /dev/null +++ b/WotBlitzStatisticsPro.Blazor/Pages/WgLoginDialog.razor @@ -0,0 +1,68 @@ +@using MediatR +@using WotBlitzStatisticsPro.Blazor.Messages +@using WotBlitzStatisticsPro.Blazor.Model +@using WotBlitzStatisticsPro.Blazor.Services +@inject DialogService DialogService +@inject IMediator Mediator +@inject ILocalStorageService LocalStorageService +@inject IStringLocalizer Localize + +
+

@Localize["LoginConsent"]

+
+
+
+ +
+
+ + + +
+
+
+
+ + +
+
+ +@code { + RealmType _currentRealmType = RealmType.Eu; + + readonly List _realms = new() + { + new(RealmType.Eu, "/realm/region.eu.scale-200.png"), + new(RealmType.Ru, "/realm/region.ru.scale-200.png"), + new(RealmType.Na, "/realm/region.na.scale-200.png"), + new(RealmType.Asia, "/realm/region.asia.scale-200.png"), + }; + + protected override async Task OnInitializedAsync() + { + var settings = await LocalStorageService.ReadSettings(); + _currentRealmType = settings.RealmType; + } + + public async Task OnRealmChanged(object value) + { + if (value is RealmType realm) + { + await Mediator.Publish(new ChangeCurrentRealmTypeMessage(realm)); + } + } + + public async Task RedirectToWg() + { + await Mediator.Publish(new RedirectToWgLoginMessage(_currentRealmType)); + + DialogService.Close(true); + } + +} diff --git a/WotBlitzStatisticsPro.Blazor/Resources/App.de.resx b/WotBlitzStatisticsPro.Blazor/Resources/App.de.resx index dbccd7c..da1b3d5 100644 --- a/WotBlitzStatisticsPro.Blazor/Resources/App.de.resx +++ b/WotBlitzStatisticsPro.Blazor/Resources/App.de.resx @@ -120,6 +120,12 @@ Schlachten + + Abbrechen + + + Weiter + Erstellt @@ -138,6 +144,9 @@ Anmelden mit WG.net-ID + + Sie werden nun auf die WG-Anmeldeseite weitergeleitet. Autorisierte Benutzer haben die Möglichkeit, ihren Statistikverlauf zu speichern, der nur Ihnen zur Verfügung steht. Diese Anwendung speichert keine persönlichen Informationen über die Spieler, ihre Benutzernamen, Passwörter, E-Mails und spielinternen Ressourcen. Außerdem können Sie sich nach dem Einloggen mit dem Speichern oder Löschen des Verlaufs Ihrer Kontostatistiken auf dem Server abmelden. Indem Sie auf Weiter klicken, erklären Sie sich mit diesen Informationen einverstanden + Mitglieder @@ -147,6 +156,9 @@ vor Monaten + + Region + Suchen @@ -165,4 +177,7 @@ vor Jahren + + Sie sind dabei, sich anzumelden + \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Blazor/Resources/App.resx b/WotBlitzStatisticsPro.Blazor/Resources/App.resx index 4fdb1b6..59275a1 100644 --- a/WotBlitzStatisticsPro.Blazor/Resources/App.resx +++ b/WotBlitzStatisticsPro.Blazor/Resources/App.resx @@ -1,101 +1,123 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + You will now be redirected to the WG login page. Authorized users have the ability to save the history of their statistics, which will be available only for you. This application does not store any personal information about the players, their logins, passwords e-mail and intra-game resources. Also after logging in you will be able to log out with the saving or deleting the history of your account statistics on the server. By clicking Continue, you agree with this information + \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Blazor/Resources/App.ru.resx b/WotBlitzStatisticsPro.Blazor/Resources/App.ru.resx index e384d34..214d586 100644 --- a/WotBlitzStatisticsPro.Blazor/Resources/App.ru.resx +++ b/WotBlitzStatisticsPro.Blazor/Resources/App.ru.resx @@ -120,6 +120,12 @@ Количество боёв + + Отмена + + + Далее + Создан @@ -138,6 +144,9 @@ Войти с WG.net ID + + Сейчас вы будете перенаправлены на страницу авторизации WG. Авторизованные пользователи получают возможность сохранять историю своей статистики, которая будет доступна только вам. Данное приложение не хранит никакой личной информации об игроках, их логинов, паролей e-mail-ов и внутреигровых ресурсах. Так же после авторизации вы будете иметь возможность выйти с сохранением или удалением истории статистики вашего аккаунта на сервере. Нажимая кнопку Далее, вы соглашаетесь с данной информацией + Участников @@ -147,6 +156,9 @@ месяцев назад + + Регион + Поиск @@ -165,4 +177,7 @@ лет назад + + Вы собираетесь войти в систему + \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Blazor/Services/GraphQlBackendService.cs b/WotBlitzStatisticsPro.Blazor/Services/GraphQlBackendService.cs index df9b654..f162f26 100644 --- a/WotBlitzStatisticsPro.Blazor/Services/GraphQlBackendService.cs +++ b/WotBlitzStatisticsPro.Blazor/Services/GraphQlBackendService.cs @@ -95,5 +95,9 @@ namespace WotBlitzStatisticsPro.Blazor.Services } } + public Task GetWgLoginUrl(RealmType realmType) + { + throw new System.NotImplementedException(); + } } } \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Blazor/Services/IGraphQlBackendService.cs b/WotBlitzStatisticsPro.Blazor/Services/IGraphQlBackendService.cs index fa932fc..f9ac999 100644 --- a/WotBlitzStatisticsPro.Blazor/Services/IGraphQlBackendService.cs +++ b/WotBlitzStatisticsPro.Blazor/Services/IGraphQlBackendService.cs @@ -17,5 +17,7 @@ namespace WotBlitzStatisticsPro.Blazor.Services Task<(IAccount accountInfo, IReadOnlyList achievementsBySection)> GetPlayerInfo( long accountId, RealmType realmType); + + Task GetWgLoginUrl(RealmType realmType); } } \ No newline at end of file diff --git a/WotBlitzStatisticsPro.Blazor/Services/Mock/GraphQlBackendMockService.cs b/WotBlitzStatisticsPro.Blazor/Services/Mock/GraphQlBackendMockService.cs index 427926a..01b20fe 100644 --- a/WotBlitzStatisticsPro.Blazor/Services/Mock/GraphQlBackendMockService.cs +++ b/WotBlitzStatisticsPro.Blazor/Services/Mock/GraphQlBackendMockService.cs @@ -196,6 +196,12 @@ namespace WotBlitzStatisticsPro.Blazor.Services.Mock return (player, achievements?.Sections); } + public Task GetWgLoginUrl(RealmType realmType) + { + return Task.FromResult( + "https://api.worldoftanks.eu/wot/auth/login/?application_id=adc1387489cf9fc8d9a1d85dbd27763d"); + } + private string FakerLanguage(RequestLanguage language) { switch (language) diff --git a/WotBlitzStatisticsPro.Blazor/Services/WargamingLoginService.cs b/WotBlitzStatisticsPro.Blazor/Services/WargamingLoginService.cs new file mode 100644 index 0000000..cee10f0 --- /dev/null +++ b/WotBlitzStatisticsPro.Blazor/Services/WargamingLoginService.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using MediatR; +using Microsoft.Extensions.Localization; +using Radzen; +using WotBlitzStatisticsPro.Blazor.Messages; +using WotBlitzStatisticsPro.Blazor.Pages; + +namespace WotBlitzStatisticsPro.Blazor.Services +{ + public class WargamingLoginService: INotificationHandler, INotificationHandler + { + private readonly IGraphQlBackendService _graphQlBackendService; + private readonly DialogService _dialogService; + private readonly IStringLocalizer _localizer; + + public WargamingLoginService( + IGraphQlBackendService graphQlBackendService, + DialogService dialogService, + IStringLocalizer localizer) + { + _graphQlBackendService = graphQlBackendService; + _dialogService = dialogService; + _localizer = localizer; + } + + public async Task Handle(LoginToWgMessage notification, CancellationToken cancellationToken) + { + await _dialogService.OpenAsync(_localizer.GetString("You're about to login"), + null, + new DialogOptions() { Width = "310px", Height = "530px" }); + + } + + public async Task Handle(RedirectToWgLoginMessage notification, CancellationToken cancellationToken) + { + var url = await _graphQlBackendService.GetWgLoginUrl(notification.Realm); + // ToDo: take a look to redirect message in previous app reincarnation + url = $"{url}&redirect_uri=https://developers.wargaming.net/reference/all/wot/auth/login/"; + } + } +} \ No newline at end of file