Skip to content

Commit f2d6780

Browse files
authored
Fix incorrect missing authentication dialog trigger (#3703)
1 parent 50e7b68 commit f2d6780

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

core/merginapi.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,7 @@ bool MerginApi::validateAuth()
14531453
return false;
14541454
}
14551455

1456-
if ( mUserAuth->authToken().isEmpty() || mUserAuth->tokenExpiration() < QDateTime().currentDateTime().toUTC() )
1456+
if ( mUserAuth->authToken().isEmpty() || mUserAuth->tokenExpiration() < QDateTime().currentDateTimeUtc() )
14571457
{
14581458
authorize( mUserAuth->username(), mUserAuth->password() );
14591459
CoreUtils::log( QStringLiteral( "MerginApi" ), QStringLiteral( "Requesting authorization because of missing or expired token." ) );
@@ -3967,11 +3967,9 @@ DownloadQueueItem::DownloadQueueItem( const QString &fp, qint64 s, int v, qint64
39673967
void MerginApi::reloadProjectRole( const QString &projectFullName )
39683968
{
39693969
if ( projectFullName.isEmpty() )
3970-
{
39713970
return;
3972-
}
39733971

3974-
QNetworkReply *reply = getProjectInfo( projectFullName );
3972+
QNetworkReply *reply = getProjectInfo( projectFullName, mUserAuth->isLoggedIn() ); //withAuth depends on whether user is logged in or not
39753973
if ( !reply )
39763974
return;
39773975

core/merginuserauth.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,8 @@ bool MerginUserAuth::hasValidToken() const
134134
{
135135
return !mAuthToken.isEmpty() && mTokenExpiration >= QDateTime().currentDateTimeUtc();
136136
}
137+
138+
bool MerginUserAuth::isLoggedIn()
139+
{
140+
return hasAuthData() && hasValidToken();
141+
}

core/merginuserauth.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ class MerginUserAuth: public QObject
3838
//! i.e. we should be good to do authenticated requests.
3939
Q_INVOKABLE bool hasValidToken() const;
4040

41+
/**
42+
* Returns whether user is currently logged in
43+
*/
44+
Q_INVOKABLE bool isLoggedIn();
45+
4146
void clear();
4247

4348
QString username() const;

0 commit comments

Comments
 (0)