From d39c702d0aa05e7bbf0f744a8a1f12a1fcfad961 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Fri, 6 Oct 2023 18:09:50 -0400 Subject: [PATCH] Add more error handling in auto login --- launcher/src/launchercore.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/launcher/src/launchercore.cpp b/launcher/src/launchercore.cpp index 8bd544a..1bd1f00 100755 --- a/launcher/src/launchercore.cpp +++ b/launcher/src/launchercore.cpp @@ -441,7 +441,21 @@ void LauncherCore::login(Profile *profile, const QString &username, const QStrin void LauncherCore::autoLogin(Profile *profile) { - login(profile, profile->account()->name(), profile->account()->getPassword(), profile->account()->useOTP() ? profile->account()->getOTP() : QString()); + QString otp; + if (profile->account()->useOTP()) { + if (!profile->account()->rememberOTP()) { + Q_EMIT loginError("This account does not have an OTP secret set, but requires it for login."); + return; + } + + otp = profile->account()->getOTP(); + if (otp.isEmpty()) { + Q_EMIT loginError("Failed to generate OTP, review the stored secret."); + return; + } + } + + login(profile, profile->account()->name(), profile->account()->getPassword(), otp); } GameInstaller *LauncherCore::createInstaller(Profile *profile)