FacebookAuthentication::FacebookAuthentication(QObject *parent)
: QObject(parent),
- m_freshLogin(false)
+ m_freshLogin(false),
+ m_loginAttempts(0)
+
{
qDebug() << __PRETTY_FUNCTION__;
else if ( callbackUrl.indexOf(LOGIN_FAILURE_REPLY) == 0){
qWarning() << "login failure" << endl;
qDebug() << callbackUrl;
- clearAccountInformation(true);
- if(m_freshLogin) {
- emit error(LOGIN_FAILED);
- emit loginFailure();
- }
- else {
- m_freshLogin = true;
- emit error(SESSION_EXPIRED);
+ ++m_loginAttempts;
+ /* emit loginFailure for every second login attemps, since webview loads login
+ error page (loadingDone() signal is emitted) and we need to avoid that because
+ at this point we don't have new login parameters */
+ if(m_loginAttempts % 2) {
+ clearAccountInformation(true);
+ if(m_freshLogin) {
+ emit error(LOGIN_FAILED);
+ emit loginFailure();
+ }
+ else {
+ m_freshLogin = true;
+ emit error(SESSION_EXPIRED);
+ }
}
}
else if(callbackUrl.indexOf(LOGIN_PAGE) == 0) {