diff --git a/src/accounts/hatchet/account/HatchetAccount.cpp b/src/accounts/hatchet/account/HatchetAccount.cpp index 0913afa82..55b287843 100644 --- a/src/accounts/hatchet/account/HatchetAccount.cpp +++ b/src/accounts/hatchet/account/HatchetAccount.cpp @@ -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; } diff --git a/src/accounts/hatchet/account/HatchetAccount.h b/src/accounts/hatchet/account/HatchetAccount.h index 6c9fe73ec..5951f281d 100644 --- a/src/accounts/hatchet/account/HatchetAccount.h +++ b/src/accounts/hatchet/account/HatchetAccount.h @@ -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(); diff --git a/src/accounts/hatchet/account/HatchetAccountConfig.cpp b/src/accounts/hatchet/account/HatchetAccountConfig.cpp index 7708303de..c2bfdb00d 100644 --- a/src/accounts/hatchet/account/HatchetAccountConfig.cpp +++ b/src/accounts/hatchet/account/HatchetAccountConfig.cpp @@ -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(); diff --git a/src/accounts/hatchet/account/HatchetAccountConfig.h b/src/accounts/hatchet/account/HatchetAccountConfig.h index 35e3f7e57..55a4f89b7 100644 --- a/src/accounts/hatchet/account/HatchetAccountConfig.h +++ b/src/accounts/hatchet/account/HatchetAccountConfig.h @@ -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 );