1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-16 11:04:01 +02:00

Only show the OTP bits if configured on the account, in a secondary login step

This commit is contained in:
Jeff Mitchell
2013-07-26 11:34:16 -04:00
parent fe4e281ab3
commit 26d1e524d5
3 changed files with 23 additions and 14 deletions

View File

@@ -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 <QtPlugin>
#include <QFile>
@@ -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;
}

View File

@@ -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 );
}

View File

@@ -59,8 +59,8 @@
<item row="3" column="0">
<widget class="QLabel" name="otpLabel">
<property name="text">
<string>One-time
Password</string>
<string>Enter One-time
Password (OTP)</string>
</property>
</widget>
</item>
@@ -101,7 +101,7 @@ Password</string>
<item row="3" column="1">
<widget class="QLineEdit" name="otpEdit">
<property name="placeholderText">
<string>(Only if configured)</string>
<string/>
</property>
</widget>
</item>