From 26d1e524d51fbf42c3a00990d1a3c9c9ed2ba768 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 26 Jul 2013 11:34:16 -0400 Subject: [PATCH] Only show the OTP bits if configured on the account, in a secondary login step --- .../hatchet/account/HatchetAccount.cpp | 5 +--- .../hatchet/account/HatchetAccountConfig.cpp | 26 ++++++++++++++----- .../hatchet/account/HatchetAccountConfig.ui | 6 ++--- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/accounts/hatchet/account/HatchetAccount.cpp b/src/accounts/hatchet/account/HatchetAccount.cpp index 35bca4d06..b724b4829 100644 --- a/src/accounts/hatchet/account/HatchetAccount.cpp +++ b/src/accounts/hatchet/account/HatchetAccount.cpp @@ -24,7 +24,7 @@ #include "utils/Logger.h" #include "sip/HatchetSip.h" #include "utils/TomahawkUtils.h" -#include "utils/NetworkAccessManager.cpp" +#include "utils/NetworkAccessManager.h" #include #include @@ -281,7 +281,6 @@ HatchetAccount::onPasswordLoginFinished( QNetworkReply* reply, const QString& us { tLog() << Q_FUNC_INFO << "Error getting parsed reply from auth server"; emit authError( "An error occurred reading the reply from the server"); - deauthenticate(); return; } @@ -289,7 +288,6 @@ HatchetAccount::onPasswordLoginFinished( QNetworkReply* reply, const QString& us { tLog() << Q_FUNC_INFO << "Auth server returned an error"; emit authError( resp.value( "error" ).toString() ); - deauthenticate(); return; } @@ -298,7 +296,6 @@ HatchetAccount::onPasswordLoginFinished( QNetworkReply* reply, const QString& us { tLog() << Q_FUNC_INFO << "Auth server nonce value does not match!"; emit authError( "The nonce value was incorrect. YOUR ACCOUNT MAY BE COMPROMISED." ); - deauthenticate(); return; } diff --git a/src/accounts/hatchet/account/HatchetAccountConfig.cpp b/src/accounts/hatchet/account/HatchetAccountConfig.cpp index cecd2016a..00e81965b 100644 --- a/src/accounts/hatchet/account/HatchetAccountConfig.cpp +++ b/src/accounts/hatchet/account/HatchetAccountConfig.cpp @@ -76,11 +76,13 @@ HatchetAccountConfig::~HatchetAccountConfig() void HatchetAccountConfig::login() { + tLog() << Q_FUNC_INFO; const ButtonAction action = static_cast< ButtonAction>( m_ui->loginButton->property( "action" ).toInt() ); if ( action == Login ) { // Log in mode + tLog() << Q_FUNC_INFO << "Logging in..."; m_account->loginWithPassword( m_ui->usernameEdit->text(), m_ui->passwordEdit->text(), m_ui->otpEdit->text() ); } else if ( action == Logout ) @@ -110,9 +112,6 @@ HatchetAccountConfig::fieldsChanged() m_ui->loginButton->setEnabled( !username.isEmpty() && !password.isEmpty() && action == Login ); m_ui->errorLabel->clear(); - - if ( action == Login ) - m_ui->loginButton->setText( tr( "Login" ) ); } @@ -132,7 +131,7 @@ HatchetAccountConfig::showLoggedIn() m_ui->errorLabel->clear(); m_ui->errorLabel->hide(); - m_ui->loginButton->setText( "Log out" ); + m_ui->loginButton->setText( tr("Log out") ); m_ui->loginButton->setProperty( "action", Logout ); m_ui->loginButton->setDefault( true ); } @@ -145,15 +144,16 @@ HatchetAccountConfig::showLoggedOut() m_ui->usernameEdit->show(); m_ui->passwordLabel->show(); m_ui->passwordEdit->show(); - m_ui->otpEdit->show(); - m_ui->otpLabel->show(); + m_ui->otpLabel->hide(); + m_ui->otpEdit->hide(); + m_ui->otpEdit->clear(); m_ui->loggedInLabel->clear(); m_ui->loggedInLabel->hide(); m_ui->errorLabel->clear(); - m_ui->loginButton->setText( "Login" ); + m_ui->loginButton->setText( tr("Log in") ); m_ui->loginButton->setProperty( "action", Login ); m_ui->loginButton->setDefault( true ); } @@ -170,6 +170,18 @@ HatchetAccountConfig::accountInfoUpdated() void HatchetAccountConfig::authError( const QString &error ) { + if ( error.startsWith( "At least one OTP method is configured on this account" ) ) + { + m_ui->usernameLabel->hide(); + m_ui->usernameEdit->hide(); + m_ui->otpLabel->show(); + m_ui->otpEdit->show(); + m_ui->passwordLabel->hide(); + m_ui->passwordEdit->hide(); + m_ui->loginButton->setText( tr("Continue") ); + return; + } + m_account->deauthenticate(); QMessageBox::critical( this, "An error was encountered logging in:", error ); } diff --git a/src/accounts/hatchet/account/HatchetAccountConfig.ui b/src/accounts/hatchet/account/HatchetAccountConfig.ui index 76d33a4a9..996b05d95 100644 --- a/src/accounts/hatchet/account/HatchetAccountConfig.ui +++ b/src/accounts/hatchet/account/HatchetAccountConfig.ui @@ -59,8 +59,8 @@ - One-time -Password + Enter One-time +Password (OTP) @@ -101,7 +101,7 @@ Password - (Only if configured) +