From 65d46aa5c9b6f4cf18aec3553cb0904b043e7a98 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 16 Mar 2022 14:51:16 -0400 Subject: [PATCH] Display the actual login error message when a login failure occurs Apparently Square Enix provides a human-readable error message, so now we give that out in the message box instead of a generic "password is incorrect" message we did before. --- src/squarelauncher.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/squarelauncher.cpp b/src/squarelauncher.cpp index ed0d207..5ec3951 100644 --- a/src/squarelauncher.cpp +++ b/src/squarelauncher.cpp @@ -143,7 +143,15 @@ void SquareLauncher::login(const LoginInformation& info, const QUrl referer) { registerSession(info); } else { - auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", "Invalid username/password."); + QRegularExpression re(R"lit(window.external.user\("login=auth,ng,err,(?.*)\);)lit"); + QRegularExpressionMatch match = re.match(str); + + const auto parts = match.captured(1).split(','); + + // there's a stray quote at the end of the error string, so let's remove that + QString errorStr = match.captured(1).chopped(1); + + auto messageBox = new QMessageBox(QMessageBox::Icon::Critical, "Failed to Login", errorStr); messageBox->show(); } });