From 42f598b9d5a3f30215757a80e7ea84bd96720a41 Mon Sep 17 00:00:00 2001 From: Stanley Dimant Date: Mon, 1 Aug 2022 11:20:22 +0200 Subject: [PATCH] add intermediate version to allow usage for now --- MareAPI | 2 +- MareSynchronos/MareSynchronos.csproj | 2 +- MareSynchronos/UI/IntroUI.cs | 41 +++++++++++++------ MareSynchronos/UI/UIShared.cs | 27 ++++-------- .../WebAPI/ApIController.Functions.Files.cs | 1 + .../WebAPI/ApIController.Functions.Users.cs | 4 +- 6 files changed, 40 insertions(+), 37 deletions(-) diff --git a/MareAPI b/MareAPI index 714d990..50a447c 160000 --- a/MareAPI +++ b/MareAPI @@ -1 +1 @@ -Subproject commit 714d990c0b5492cd2a19bb021f1570c6bc10e7c3 +Subproject commit 50a447c4d0e4264fa8f08f90998c3e36e0b098e2 diff --git a/MareSynchronos/MareSynchronos.csproj b/MareSynchronos/MareSynchronos.csproj index d2c5846..4461cd4 100644 --- a/MareSynchronos/MareSynchronos.csproj +++ b/MareSynchronos/MareSynchronos.csproj @@ -3,7 +3,7 @@ - 0.2.13.0 + 0.2.14.0 https://github.com/Penumbra-Sync/client diff --git a/MareSynchronos/UI/IntroUI.cs b/MareSynchronos/UI/IntroUI.cs index 594529d..b314f6c 100644 --- a/MareSynchronos/UI/IntroUI.cs +++ b/MareSynchronos/UI/IntroUI.cs @@ -10,6 +10,7 @@ using ImGuiNET; using MareSynchronos.Managers; using MareSynchronos.Utils; using MareSynchronos.Localization; +using Dalamud.Utility; namespace MareSynchronos.UI { @@ -99,12 +100,12 @@ namespace MareSynchronos.UI var textSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel); ImGui.TextUnformatted(Strings.ToS.AgreementLabel); if (_uiShared.UidFontBuilt) ImGui.PopFont(); - + ImGui.SameLine(); var languageSize = ImGui.CalcTextSize(Strings.ToS.LanguageLabel); ImGui.SetCursorPosX(ImGui.GetWindowContentRegionMax().X - ImGui.GetWindowContentRegionMin().X - languageSize.X - 80); ImGui.SetCursorPosY(ImGui.GetCursorPosY() + textSize.Y / 2 - languageSize.Y / 2); - + ImGui.TextUnformatted(Strings.ToS.LanguageLabel); ImGui.SameLine(); ImGui.SetCursorPosY(ImGui.GetCursorPosY() + textSize.Y / 2 - (languageSize.Y + ImGui.GetStyle().FramePadding.Y) / 2); @@ -113,7 +114,7 @@ namespace MareSynchronos.UI { GetToSLocalization(_currentLanguage); } - + ImGui.Separator(); ImGui.SetWindowFontScale(1.5f); string readThis = Strings.ToS.ReadLabel; @@ -262,32 +263,46 @@ namespace MareSynchronos.UI } else { - UiShared.TextWrapped("You will now have to register at a service. You can use the provided central service or pick a custom one. " + - "There is no support for custom services from the plugin creator. Use at your own risk."); - UiShared.ColorTextWrapped("On registration on a service the plugin will create and save a secret key to your plugin configuration. " + - "Make a backup of your secret key. In case of loss, it cannot be restored. The secret key is your identification to the service " + - "to verify who you are. It is directly tied to the UID you will be receiving. In case of loss, you will have to re-register an account.", ImGuiColors.DalamudYellow); - UiShared.ColorTextWrapped("Do not ever, under any circumstances, share your secret key to anyone! Likewise do not share your Mare Synchronos plugin configuration to anyone!", ImGuiColors.DalamudYellow); - _uiShared.DrawServiceSelection(new Action(() => { }), true); + UiShared.TextWrapped("Registrations are currently closed. Join the Mare Synchronos server Discord for further information."); + + if (ImGui.Button("Mare Synchronos Discord")) + { + Util.OpenLink("https://discord.gg/mpNdkrTRjW"); + } + + UiShared.TextWrapped("I'm sorry for the inconvenience caused, however the main service suffered from a DDoS-like attack a short time ago. I am currently working hard on implementing measures to avoid such issues in the future."); + UiShared.TextWrapped("You can close this window for now."); + + ImGui.Separator(); + + UiShared.TextWrapped("If you made an account before (AND ONLY THEN) you can connect to the service using the tools provided below."); + + _uiShared.DrawServiceSelection(() => + { + SwitchToMainUi?.Invoke(); + IsOpen = false; + }, true); } } } + private string _secretKey = string.Empty; + private void GetToSLocalization(int changeLanguageTo = -1) { if (changeLanguageTo != -1) { _uiShared.LoadLocalization(_languages.ElementAt(changeLanguageTo).Value); } - + TosParagraphs = new[] { Strings.ToS.Paragraph1, Strings.ToS.Paragraph2, Strings.ToS.Paragraph3, Strings.ToS.Paragraph4, Strings.ToS.Paragraph5, Strings.ToS.Paragraph6 }; - + if (_pluginConfiguration.DarkSoulsAgreement) { GenerateDarkSoulsAgreementCaptcha(); } } - + private void GenerateDarkSoulsAgreementCaptcha() { _darkSoulsCaptcha1 = GetCaptchaTuple(); diff --git a/MareSynchronos/UI/UIShared.cs b/MareSynchronos/UI/UIShared.cs index 1ab2c35..a672960 100644 --- a/MareSynchronos/UI/UIShared.cs +++ b/MareSynchronos/UI/UIShared.cs @@ -41,6 +41,9 @@ namespace MareSynchronos.UI public static bool CtrlPressed() => (GetKeyState(0xA2) & 0x8000) != 0 || (GetKeyState(0xA3) & 0x8000) != 0; + // todo remove after rework + public ApiController ApiController => _apiController; + public UiShared(IpcManager ipcManager, ApiController apiController, FileCacheManager fileCacheManager, FileDialogManager fileDialogManager, Configuration pluginConfiguration, DalamudUtil dalamudUtil, DalamudPluginInterface pluginInterface, Dalamud.Localization localization) { _ipcManager = ipcManager; @@ -321,23 +324,7 @@ namespace MareSynchronos.UI PrintServerState(isIntroUi); - if (_apiController.ServerAlive && (!_pluginConfiguration.ClientSecret.ContainsKey(_pluginConfiguration.ApiUri) || _pluginConfiguration.ClientSecret[_pluginConfiguration.ApiUri].IsNullOrEmpty())) - { - if (!_enterSecretKey) - { - if (ImGui.Button("Register")) - { - _pluginConfiguration.FullPause = false; - _pluginConfiguration.Save(); - Task.Run(() => _apiController.Register(isIntroUi)); - ShowClientSecret = true; - callBackOnExit?.Invoke(); - } - - ImGui.SameLine(); - } - } - else + if (!_apiController.ServerAlive && (_pluginConfiguration.ClientSecret.ContainsKey(_pluginConfiguration.ApiUri) && !_pluginConfiguration.ClientSecret[_pluginConfiguration.ApiUri].IsNullOrEmpty())) { ColorTextWrapped("You already have an account on this server.", ImGuiColors.DalamudYellow); ImGui.SameLine(); @@ -380,10 +367,10 @@ namespace MareSynchronos.UI ImGui.SameLine(); if (_secretKey.Length > 0 && _secretKey.Length != 64) { - ColorTextWrapped("Your secret key must be exactly 64 characters long. If try to enter your UID here, this is incorrect." + - " If you have lost your secret key, you will need to create a new account.", ImGuiColors.DalamudRed); + UiShared.ColorTextWrapped("Your secret key must be exactly 64 characters long. If try to enter your UID here, this is incorrect." + + " Don't enter anything but a prior acquired secret key here.", ImGuiColors.DalamudRed); } - else + else if (_secretKey.Length == 64) { if (ImGui.Button("Save")) { diff --git a/MareSynchronos/WebAPI/ApIController.Functions.Files.cs b/MareSynchronos/WebAPI/ApIController.Functions.Files.cs index 1224827..6cd527e 100644 --- a/MareSynchronos/WebAPI/ApIController.Functions.Files.cs +++ b/MareSynchronos/WebAPI/ApIController.Functions.Files.cs @@ -38,6 +38,7 @@ namespace MareSynchronos.WebAPI private async Task DownloadFile(int downloadId, string hash, CancellationToken ct) { using WebClient wc = new(); + wc.Headers.Add("Authorization", SecretKey); DownloadProgressChangedEventHandler progChanged = (s, e) => { try diff --git a/MareSynchronos/WebAPI/ApIController.Functions.Users.cs b/MareSynchronos/WebAPI/ApIController.Functions.Users.cs index 6512a35..ab07b68 100644 --- a/MareSynchronos/WebAPI/ApIController.Functions.Users.cs +++ b/MareSynchronos/WebAPI/ApIController.Functions.Users.cs @@ -21,8 +21,8 @@ namespace MareSynchronos.WebAPI { if (!ServerAlive) return; Logger.Debug("Registering at service " + ApiUri); - var response = await _mareHub!.InvokeAsync(Api.InvokeUserRegister); - _pluginConfiguration.ClientSecret[ApiUri] = response; + //var response = await _mareHub!.InvokeAsync(Api.InvokeUserRegister); + //_pluginConfiguration.ClientSecret[ApiUri] = response; _pluginConfiguration.Save(); if (!isIntroUi) {