Skip to content

Commit

Permalink
[oauth2] Don't check state value if state option was never set in
Browse files Browse the repository at this point in the history
initial request

Some servers will not return an empty state, so we should not
require its existance if it was never used to start with.
  • Loading branch information
nyalldawson committed Oct 24, 2018
1 parent 7a982f5 commit 7cf4153
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/auth/oauth2/qgso2.cpp
Expand Up @@ -251,21 +251,24 @@ void QgsO2::onVerificationReceived( QMap<QString, QString> response )
return;
}

if ( response.contains( QStringLiteral( "state" ) ) )
if ( !state_.isEmpty() )
{
if ( response.value( QStringLiteral( "state" ), QStringLiteral( "ignore" ) ) != state_ )
if ( response.contains( QStringLiteral( "state" ) ) )
{
QgsDebugMsgLevel( QStringLiteral( "QgsO2::onVerificationReceived: Verification failed: (Response returned wrong state)" ), 3 ) ;
if ( response.value( QStringLiteral( "state" ), QStringLiteral( "ignore" ) ) != state_ )
{
QgsDebugMsgLevel( QStringLiteral( "QgsO2::onVerificationReceived: Verification failed: (Response returned wrong state)" ), 3 ) ;
emit linkingFailed();
return;
}
}
else
{
QgsDebugMsgLevel( QStringLiteral( "QgsO2::onVerificationReceived: Verification failed: (Response does not contain state)" ), 3 );
emit linkingFailed();
return;
}
}
else
{
QgsDebugMsgLevel( QStringLiteral( "QgsO2::onVerificationReceived: Verification failed: (Response does not contain state)" ), 3 );
emit linkingFailed();
return;
}
// Save access code
setCode( response.value( QString( O2_OAUTH2_GRANT_TYPE_CODE ) ) );
}
Expand Down

0 comments on commit 7cf4153

Please sign in to comment.