feat: WG auth dialog

This commit is contained in:
Mikhail Shabanov committed 2021-07-02 14:37:47 +02:00
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"> <data name="Battles" xml:space="preserve">
<value>Schlachten</value> <value>Schlachten</value>
</data> </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"> <data name="Created" xml:space="preserve">
<value>Erstellt</value> <value>Erstellt</value>
</data> </data>
@@ -138,6 +144,9 @@
<data name="Login with WG.net ID" xml:space="preserve"> <data name="Login with WG.net ID" xml:space="preserve">
<value>Anmelden mit WG.net-ID</value> <value>Anmelden mit WG.net-ID</value>
</data> </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"> <data name="Members" xml:space="preserve">
<value>Mitglieder</value> <value>Mitglieder</value>
</data> </data>
@@ -147,6 +156,9 @@
<data name="months ago" xml:space="preserve"> <data name="months ago" xml:space="preserve">
<value>vor Monaten</value> <value>vor Monaten</value>
</data> </data>
<data name="Region" xml:space="preserve">
<value>Region</value>
</data>
<data name="Search" xml:space="preserve"> <data name="Search" xml:space="preserve">
<value>Suchen</value> <value>Suchen</value>
</data> </data>
@@ -165,4 +177,7 @@
<data name="years ago" xml:space="preserve"> <data name="years ago" xml:space="preserve">
<value>vor Jahren</value> <value>vor Jahren</value>
</data> </data>
<data name="You're about to login" xml:space="preserve">
<value>Sie sind dabei, sich anzumelden</value>
</data>
</root> </root>
+119 -97
View File
@@ -1,101 +1,123 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <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 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
The primary goals of this format is to allow a simple XML format : using a System.ComponentModel.TypeConverter
that is mostly human readable. The generation and parsing of the : and then encoded with base64 encoding.
various data types are done through the TypeConverter classes -->
associated with the data types. <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" />
Example: <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
... ado.net/XML headers & schema ... <xsd:choice maxOccurs="unbounded">
<resheader name="resmimetype">text/microsoft-resx</resheader> <xsd:element name="metadata">
<resheader name="version">1.3</resheader> <xsd:complexType>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <xsd:sequence>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <xsd:element name="value" type="xsd:string" minOccurs="0" />
<data name="Name1">this is my long string</data> </xsd:sequence>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <xsd:attribute name="name" use="required" type="xsd:string" />
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <xsd:attribute name="type" type="xsd:string" />
[base64 mime encoded serialized .NET Framework object] <xsd:attribute name="mimetype" type="xsd:string" />
</data> <xsd:attribute ref="xml:space" />
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> </xsd:complexType>
[base64 mime encoded string representing a byte array form of the .NET Framework object] </xsd:element>
</data> <xsd:element name="assembly">
<xsd:complexType>
There are any number of "resheader" rows that contain simple <xsd:attribute name="alias" type="xsd:string" />
name/value pairs. <xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
Each data row contains a name, and value. The row also contains a </xsd:element>
type or mimetype. Type corresponds to a .NET class that support <xsd:element name="data">
text/value conversion through the TypeConverter architecture. <xsd:complexType>
Classes that don't support this are serialized and stored with the <xsd:sequence>
mimetype set. <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
The mimetype is used for serialized objects, and tells the </xsd:sequence>
ResXResourceReader how to depersist the object. This is currently not <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
extensible. For a given mimetype the value must be set accordingly: <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
Note - application/x-microsoft.net.object.binary.base64 is the format <xsd:attribute ref="xml:space" />
that the ResXResourceWriter will generate, however the reader can </xsd:complexType>
read any of the formats listed below. </xsd:element>
<xsd:element name="resheader">
mimetype: application/x-microsoft.net.object.binary.base64 <xsd:complexType>
value : The object must be serialized with <xsd:sequence>
: System.Serialization.Formatters.Binary.BinaryFormatter <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
: and then encoded with base64 encoding. </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
mimetype: application/x-microsoft.net.object.soap.base64 </xsd:complexType>
value : The object must be serialized with </xsd:element>
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter </xsd:choice>
: and then encoded with base64 encoding. </xsd:complexType>
</xsd:element>
mimetype: application/x-microsoft.net.object.bytearray.base64 </xsd:schema>
value : The object must be serialized into a byte array <resheader name="resmimetype">
: using a System.ComponentModel.TypeConverter <value>text/microsoft-resx</value>
: and then encoded with base64 encoding. </resheader>
--> <resheader name="version">
<value>2.0</value>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> </resheader>
<xsd:element name="root" msdata:IsDataSet="true"> <resheader name="reader">
<xsd:complexType> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<xsd:choice maxOccurs="unbounded"> </resheader>
<xsd:element name="data"> <resheader name="writer">
<xsd:complexType> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<xsd:sequence> </resheader>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <data name="LoginConsent" xml:space="preserve">
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> <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>
</xsd:sequence> </data>
<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>
</root> </root>
@@ -120,6 +120,12 @@
<data name="Battles" xml:space="preserve"> <data name="Battles" xml:space="preserve">
<value>Количество боёв</value> <value>Количество боёв</value>
</data> </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"> <data name="Created" xml:space="preserve">
<value>Создан</value> <value>Создан</value>
</data> </data>
@@ -138,6 +144,9 @@
<data name="Login with WG.net ID" xml:space="preserve"> <data name="Login with WG.net ID" xml:space="preserve">
<value>Войти с WG.net ID</value> <value>Войти с WG.net ID</value>
</data> </data>
<data name="LoginConsent" xml:space="preserve">
<value>Сейчас вы будете перенаправлены на страницу авторизации WG. Авторизованные пользователи получают возможность сохранять историю своей статистики, которая будет доступна только вам. Данное приложение не хранит никакой личной информации об игроках, их логинов, паролей e-mail-ов и внутреигровых ресурсах. Так же после авторизации вы будете иметь возможность выйти с сохранением или удалением истории статистики вашего аккаунта на сервере. Нажимая кнопку Далее, вы соглашаетесь с данной информацией</value>
</data>
<data name="Members" xml:space="preserve"> <data name="Members" xml:space="preserve">
<value>Участников</value> <value>Участников</value>
</data> </data>
@@ -147,6 +156,9 @@
<data name="months ago" xml:space="preserve"> <data name="months ago" xml:space="preserve">
<value>месяцев назад</value> <value>месяцев назад</value>
</data> </data>
<data name="Region" xml:space="preserve">
<value>Регион</value>
</data>
<data name="Search" xml:space="preserve"> <data name="Search" xml:space="preserve">
<value>Поиск</value> <value>Поиск</value>
</data> </data>
@@ -165,4 +177,7 @@
<data name="years ago" xml:space="preserve"> <data name="years ago" xml:space="preserve">
<value>лет назад</value> <value>лет назад</value>
</data> </data>
<data name="You're about to login" xml:space="preserve">
<value>Вы собираетесь войти в систему</value>
</data>
</root> </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( Task<(IAccount accountInfo, IReadOnlyList<ISection> achievementsBySection)> GetPlayerInfo(
long accountId, long accountId,
RealmType realmType); RealmType realmType);
Task<string> GetWgLoginUrl(RealmType realmType);
} }
} }
@@ -196,6 +196,12 @@ namespace WotBlitzStatisticsPro.Blazor.Services.Mock
return (player, achievements?.Sections); 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) private string FakerLanguage(RequestLanguage language)
{ {
switch (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/";
}
}
}