From f2381d0bd2fb92850c697be6ebdaec7ba63ab072 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sun, 28 Jul 2024 14:18:18 -0700 Subject: [PATCH 1/2] Properly format error messages for OauthLoginException --- .../Components/MainPage/MainPage.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs index fa7280ad..3d3aa695 100644 --- a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs +++ b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs @@ -245,14 +245,18 @@ public async Task Login(string username, string password, bool isOtp, bool private async Task TryProcessLoginResult(Launcher.LoginResult loginResult, bool isSteam, LoginAction action) { - if (loginResult.State == Launcher.LoginState.NoService) + // Format error message in the way OauthLoginException expects. + var preErrorMsg = "window.external.user(\"login=auth,ng,err,"; + var postErrorMsg = "\");"; + + if (loginResult.State == Launcher.LoginState.NoService || Environment.GetEnvironmentVariable("XL_LOGIN_TEST") == "sub") { - throw new OauthLoginException("No service account or subscription"); + throw new OauthLoginException(preErrorMsg + "No service account or subscription" + postErrorMsg); } - if (loginResult.State == Launcher.LoginState.NoTerms) + if (loginResult.State == Launcher.LoginState.NoTerms || Environment.GetEnvironmentVariable("XL_LOGIN_TEST") == "terms") { - throw new OauthLoginException("Need to accept terms of use"); + throw new OauthLoginException(preErrorMsg + "Need to accept terms of use" + postErrorMsg); } /* @@ -267,7 +271,7 @@ private async Task TryProcessLoginResult(Launcher.LoginResult loginResult, * In the future we may be able to just delete /boot and run boot patches again, but this doesn't happen often enough to warrant the * complexity and if boot is fucked game probably is too. */ - if (loginResult.State == Launcher.LoginState.NeedsPatchBoot) + if (loginResult.State == Launcher.LoginState.NeedsPatchBoot || Environment.GetEnvironmentVariable("XL_LOGIN_TEST") == "boot") { /* CustomMessageBox.Show( @@ -276,7 +280,7 @@ private async Task TryProcessLoginResult(Launcher.LoginResult loginResult, "Error", MessageBoxButton.OK, MessageBoxImage.Error, parentWindow: _window); */ - throw new OauthLoginException("Boot conflict, need reinstall"); + throw new OauthLoginException(preErrorMsg + "Boot conflict, need reinstall" + postErrorMsg); } if (action == LoginAction.Repair) @@ -298,7 +302,7 @@ private async Task TryProcessLoginResult(Launcher.LoginResult loginResult, "The server sent an incorrect response - the repair cannot proceed."), "Error", MessageBoxButton.OK, MessageBoxImage.Error, parentWindow: _window); */ - throw new OauthLoginException("Repair login state not NeedsPatchGame"); + throw new OauthLoginException(preErrorMsg + "Repair login state not NeedsPatchGame" + postErrorMsg); } } catch (Exception) From 6903fb9f71aebafbd615d11de8c5c8d9337a6e14 Mon Sep 17 00:00:00 2001 From: Rankyn Bass Date: Sun, 28 Jul 2024 14:27:43 -0700 Subject: [PATCH 2/2] Remove debug vars --- src/XIVLauncher.Core/Components/MainPage/MainPage.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs index 3d3aa695..69806061 100644 --- a/src/XIVLauncher.Core/Components/MainPage/MainPage.cs +++ b/src/XIVLauncher.Core/Components/MainPage/MainPage.cs @@ -249,12 +249,12 @@ private async Task TryProcessLoginResult(Launcher.LoginResult loginResult, var preErrorMsg = "window.external.user(\"login=auth,ng,err,"; var postErrorMsg = "\");"; - if (loginResult.State == Launcher.LoginState.NoService || Environment.GetEnvironmentVariable("XL_LOGIN_TEST") == "sub") + if (loginResult.State == Launcher.LoginState.NoService) { throw new OauthLoginException(preErrorMsg + "No service account or subscription" + postErrorMsg); } - if (loginResult.State == Launcher.LoginState.NoTerms || Environment.GetEnvironmentVariable("XL_LOGIN_TEST") == "terms") + if (loginResult.State == Launcher.LoginState.NoTerms) { throw new OauthLoginException(preErrorMsg + "Need to accept terms of use" + postErrorMsg); } @@ -271,7 +271,7 @@ private async Task TryProcessLoginResult(Launcher.LoginResult loginResult, * In the future we may be able to just delete /boot and run boot patches again, but this doesn't happen often enough to warrant the * complexity and if boot is fucked game probably is too. */ - if (loginResult.State == Launcher.LoginState.NeedsPatchBoot || Environment.GetEnvironmentVariable("XL_LOGIN_TEST") == "boot") + if (loginResult.State == Launcher.LoginState.NeedsPatchBoot) { /* CustomMessageBox.Show(