1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 22:26:32 +02:00

Not all 401s are OTP needed

This commit is contained in:
Jeff Mitchell
2013-09-06 16:06:10 -04:00
parent 11681c5b35
commit f3b7fc6cae
4 changed files with 14 additions and 14 deletions

View File

@@ -280,27 +280,27 @@ HatchetAccount::onPasswordLoginFinished( QNetworkReply* reply, const QString& us
if ( !ok )
{
tLog() << Q_FUNC_INFO << "Error finding status code from auth server";
emit authError( "An error occurred getting the status code from the server", 0 );
emit authError( "An error occurred getting the status code from the server", 0, QVariantMap() );
return;
}
const QVariantMap resp = parseReply( reply, ok );
if ( !ok )
{
tLog() << Q_FUNC_INFO << "Error getting parsed reply from auth server";
emit authError( "An error occurred reading the reply from the authentication server", statusCode );
emit authError( "An error occurred reading the reply from the authentication server", statusCode, resp );
return;
}
if ( statusCode >= 500 )
{
tLog() << Q_FUNC_INFO << "Encountered internal error from auth server, cannot continue";
emit authError( "The authentication server reported an internal error, please try again later", statusCode );
emit authError( "The authentication server reported an internal error, please try again later", statusCode, resp );
return;
}
if ( statusCode >= 400 )
{
QString errString = resp.value( "result" ).toMap().value( "errorinfo" ).toMap().value( "description" ).toString();
tLog() << Q_FUNC_INFO << "An error was returned from the authentication server: " << errString;
emit authError( errString, statusCode );
emit authError( errString, statusCode, resp );
return;
}
@@ -308,7 +308,7 @@ HatchetAccount::onPasswordLoginFinished( QNetworkReply* reply, const QString& us
if ( nonce != m_uuid )
{
tLog() << Q_FUNC_INFO << "Auth server nonce value does not match!";
emit authError( "The nonce value was incorrect. YOUR ACCOUNT MAY BE COMPROMISED.", statusCode );
emit authError( "The nonce value was incorrect. YOUR ACCOUNT MAY BE COMPROMISED.", statusCode, resp );
return;
}
@@ -342,27 +342,27 @@ HatchetAccount::onFetchAccessTokensFinished()
if ( !ok )
{
tLog() << Q_FUNC_INFO << "Error finding status code from auth server";
emit authError( "An error occurred getting the status code from the server", 0 );
emit authError( "An error occurred getting the status code from the server", 0, QVariantMap() );
return;
}
const QVariantMap resp = parseReply( reply, ok );
if ( !ok )
{
tLog() << Q_FUNC_INFO << "Error getting parsed reply from auth server";
emit authError( "An error occurred reading the reply from the authentication server", statusCode );
emit authError( "An error occurred reading the reply from the authentication server", statusCode, resp );
return;
}
if ( statusCode >= 500 )
{
tLog() << Q_FUNC_INFO << "Encountered internal error from auth server, cannot continue";
emit authError( "The authentication server reported an internal error, please try again later", statusCode );
emit authError( "The authentication server reported an internal error, please try again later", statusCode, resp );
return;
}
if ( statusCode >= 400 )
{
QString errString = resp.value( "result" ).toMap().value( "errorinfo" ).toMap().value( "description" ).toString();
tLog() << Q_FUNC_INFO << "An error was returned from the authentication server: " << errString;
emit authError( errString, statusCode );
emit authError( errString, statusCode, resp );
return;
}

View File

@@ -96,7 +96,7 @@ public:
QString authUrlForService( const Service& service ) const;
signals:
void authError( QString error, int statusCode );
void authError( QString error, int statusCode, const QVariantMap );
void deauthenticated();
void accessTokensFetched();

View File

@@ -54,7 +54,7 @@ HatchetAccountConfig::HatchetAccountConfig( HatchetAccount* account )
connect( m_ui->passwordEdit, SIGNAL( textChanged( QString ) ), this, SLOT( fieldsChanged() ) );
connect( m_ui->otpEdit, SIGNAL( textChanged( QString ) ), this, SLOT( fieldsChanged() ) );
connect( m_account, SIGNAL( authError( QString, int ) ), this, SLOT( authError( QString, int ) ) );
connect( m_account, SIGNAL( authError( QString, int, QVariantMap ) ), this, SLOT( authError( QString, int, QVariantMap ) ) );
connect( m_account, SIGNAL( deauthenticated() ), this, SLOT( showLoggedOut() ) );
connect( m_account, SIGNAL( accessTokensFetched() ), this, SLOT( accountInfoUpdated() ) );
@@ -168,9 +168,9 @@ HatchetAccountConfig::accountInfoUpdated()
void
HatchetAccountConfig::authError( const QString &error, int statusCode )
HatchetAccountConfig::authError( const QString &error, int statusCode, const QVariantMap& resp )
{
if ( statusCode == 401 )
if ( statusCode == 401 && resp["result"].toMap()["errorinfo"].toMap().contains("missingotp") )
{
m_ui->usernameLabel->hide();
m_ui->usernameEdit->hide();

View File

@@ -52,7 +52,7 @@ private slots:
void accountInfoUpdated();
void authError( const QString& error, int statusCode );
void authError( const QString& error, int statusCode, const QVariantMap& resp );
protected:
//virtual void changeEvent( QEvent* event );