Skip to content

Commit

Permalink
Properly format error messages for OauthLoginException
Browse files Browse the repository at this point in the history
  • Loading branch information
rankynbass committed Jul 28, 2024
1 parent 71a9b7b commit f2381d0
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/XIVLauncher.Core/Components/MainPage/MainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,18 @@ public async Task<bool> Login(string username, string password, bool isOtp, bool

private async Task<bool> 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);
}

/*
Expand All @@ -267,7 +271,7 @@ private async Task<bool> 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(
Expand All @@ -276,7 +280,7 @@ private async Task<bool> 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)
Expand All @@ -298,7 +302,7 @@ private async Task<bool> 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)
Expand Down

0 comments on commit f2381d0

Please sign in to comment.