mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-21 02:17:20 +02:00
feat: WG auth dialog
This commit is contained in:
1 parent
5d66c3641f
commit
83681c6b42
9 files changed
+287
-97
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<App> Localize
|
||||
|
||||
<div class="row">
|
||||
<p><small> @Localize["LoginConsent"]</small></p>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-5 align-items-center d-flex">
|
||||
<RadzenLabel Text=@Localize["Region"] />
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<RadzenDropDown @bind-Value=@_currentRealmType
|
||||
Data=@_realms
|
||||
ValueProperty="RealmType"
|
||||
Style="margin-bottom: 10px; width: 87px"
|
||||
Change="@OnRealmChanged">
|
||||
<Template>
|
||||
<img src="@(((RealmSelector) context).RealmImage)" style="height: 27px" />
|
||||
</Template>
|
||||
</RadzenDropDown>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<RadzenButton Text=@Localize["Cancel"] Click="() => DialogService.Close(false)" ButtonStyle="ButtonStyle.Secondary" Style="margin-bottom: 10px; width: 130px" />
|
||||
<RadzenButton Text=@Localize["Continue"] Click="RedirectToWg" Style="margin-bottom: 10px; width: 130px" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
RealmType _currentRealmType = RealmType.Eu;
|
||||
|
||||
readonly List<RealmSelector> _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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -120,6 +120,12 @@
|
||||
<data name="Battles" xml:space="preserve">
|
||||
<value>Schlachten</value>
|
||||
</data>
|
||||
<data name="Cancel" xml:space="preserve">
|
||||
<value>Abbrechen</value>
|
||||
</data>
|
||||
<data name="Continue" xml:space="preserve">
|
||||
<value>Weiter</value>
|
||||
</data>
|
||||
<data name="Created" xml:space="preserve">
|
||||
<value>Erstellt</value>
|
||||
</data>
|
||||
@@ -138,6 +144,9 @@
|
||||
<data name="Login with WG.net ID" xml:space="preserve">
|
||||
<value>Anmelden mit WG.net-ID</value>
|
||||
</data>
|
||||
<data name="LoginConsent" xml:space="preserve">
|
||||
<value>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</value>
|
||||
</data>
|
||||
<data name="Members" xml:space="preserve">
|
||||
<value>Mitglieder</value>
|
||||
</data>
|
||||
@@ -147,6 +156,9 @@
|
||||
<data name="months ago" xml:space="preserve">
|
||||
<value>vor Monaten</value>
|
||||
</data>
|
||||
<data name="Region" xml:space="preserve">
|
||||
<value>Region</value>
|
||||
</data>
|
||||
<data name="Search" xml:space="preserve">
|
||||
<value>Suchen</value>
|
||||
</data>
|
||||
@@ -165,4 +177,7 @@
|
||||
<data name="years ago" xml:space="preserve">
|
||||
<value>vor Jahren</value>
|
||||
</data>
|
||||
<data name="You're about to login" xml:space="preserve">
|
||||
<value>Sie sind dabei, sich anzumelden</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1,101 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
Version 1.3
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">1.3</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1">this is my long string</data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
[base64 mime encoded serialized .NET Framework object]
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
[base64 mime encoded string representing a byte array form of the .NET Framework object]
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
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.
|
||||
-->
|
||||
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>1.3</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
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.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="LoginConsent" xml:space="preserve">
|
||||
<value>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</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -120,6 +120,12 @@
|
||||
<data name="Battles" xml:space="preserve">
|
||||
<value>Количество боёв</value>
|
||||
</data>
|
||||
<data name="Cancel" xml:space="preserve">
|
||||
<value>Отмена</value>
|
||||
</data>
|
||||
<data name="Continue" xml:space="preserve">
|
||||
<value>Далее</value>
|
||||
</data>
|
||||
<data name="Created" xml:space="preserve">
|
||||
<value>Создан</value>
|
||||
</data>
|
||||
@@ -138,6 +144,9 @@
|
||||
<data name="Login with WG.net ID" xml:space="preserve">
|
||||
<value>Войти с WG.net ID</value>
|
||||
</data>
|
||||
<data name="LoginConsent" xml:space="preserve">
|
||||
<value>Сейчас вы будете перенаправлены на страницу авторизации WG. Авторизованные пользователи получают возможность сохранять историю своей статистики, которая будет доступна только вам. Данное приложение не хранит никакой личной информации об игроках, их логинов, паролей e-mail-ов и внутреигровых ресурсах. Так же после авторизации вы будете иметь возможность выйти с сохранением или удалением истории статистики вашего аккаунта на сервере. Нажимая кнопку Далее, вы соглашаетесь с данной информацией</value>
|
||||
</data>
|
||||
<data name="Members" xml:space="preserve">
|
||||
<value>Участников</value>
|
||||
</data>
|
||||
@@ -147,6 +156,9 @@
|
||||
<data name="months ago" xml:space="preserve">
|
||||
<value>месяцев назад</value>
|
||||
</data>
|
||||
<data name="Region" xml:space="preserve">
|
||||
<value>Регион</value>
|
||||
</data>
|
||||
<data name="Search" xml:space="preserve">
|
||||
<value>Поиск</value>
|
||||
</data>
|
||||
@@ -165,4 +177,7 @@
|
||||
<data name="years ago" xml:space="preserve">
|
||||
<value>лет назад</value>
|
||||
</data>
|
||||
<data name="You're about to login" xml:space="preserve">
|
||||
<value>Вы собираетесь войти в систему</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -95,5 +95,9 @@ namespace WotBlitzStatisticsPro.Blazor.Services
|
||||
}
|
||||
}
|
||||
|
||||
public Task<string> GetWgLoginUrl(RealmType realmType)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,5 +17,7 @@ namespace WotBlitzStatisticsPro.Blazor.Services
|
||||
Task<(IAccount accountInfo, IReadOnlyList<ISection> achievementsBySection)> GetPlayerInfo(
|
||||
long accountId,
|
||||
RealmType realmType);
|
||||
|
||||
Task<string> GetWgLoginUrl(RealmType realmType);
|
||||
}
|
||||
}
|
||||
@@ -196,6 +196,12 @@ namespace WotBlitzStatisticsPro.Blazor.Services.Mock
|
||||
return (player, achievements?.Sections);
|
||||
}
|
||||
|
||||
public Task<string> GetWgLoginUrl(RealmType realmType)
|
||||
{
|
||||
return Task.FromResult(
|
||||
"https://api.worldoftanks.eu/wot/auth/login/?application_id=adc1387489cf9fc8d9a1d85dbd27763d");
|
||||
}
|
||||
|
||||
private string FakerLanguage(RequestLanguage language)
|
||||
{
|
||||
switch (language)
|
||||
|
||||
@@ -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<LoginToWgMessage>, INotificationHandler<RedirectToWgLoginMessage>
|
||||
{
|
||||
private readonly IGraphQlBackendService _graphQlBackendService;
|
||||
private readonly DialogService _dialogService;
|
||||
private readonly IStringLocalizer<App> _localizer;
|
||||
|
||||
public WargamingLoginService(
|
||||
IGraphQlBackendService graphQlBackendService,
|
||||
DialogService dialogService,
|
||||
IStringLocalizer<App> localizer)
|
||||
{
|
||||
_graphQlBackendService = graphQlBackendService;
|
||||
_dialogService = dialogService;
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
public async Task Handle(LoginToWgMessage notification, CancellationToken cancellationToken)
|
||||
{
|
||||
await _dialogService.OpenAsync<WgLoginDialog>(_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/";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user