Skip to content

Commit 2697960

Browse files
committed
last update
1 parent 00ca4d1 commit 2697960

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

core/merginapi.cpp

Lines changed: 3 additions & 10 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." ) );
@@ -3966,12 +3966,10 @@ DownloadQueueItem::DownloadQueueItem( const QString &fp, qint64 s, int v, qint64
39663966

39673967
void MerginApi::reloadProjectRole( const QString &projectFullName )
39683968
{
3969-
if ( projectFullName.isEmpty() || !isLoggedIn() )
3970-
{
3969+
if ( projectFullName.isEmpty() )
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

@@ -4053,8 +4051,3 @@ void MerginApi::setNetworkManager( QNetworkAccessManager *manager )
40534051

40544052
emit networkManagerChanged();
40554053
}
4056-
4057-
bool MerginApi::isLoggedIn() const
4058-
{
4059-
return mUserAuth->hasAuthData() && !mUserAuth->authToken().isEmpty() && !( mUserAuth->tokenExpiration() < QDateTime().currentDateTime().toUTC() );
4060-
}

core/merginapi.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,6 @@ class MerginApi: public QObject
593593
*/
594594
void setNetworkManager( QNetworkAccessManager *manager );
595595

596-
/**
597-
* Returns whether user is currently logged in
598-
*/
599-
Q_INVOKABLE bool isLoggedIn() const;
600-
601596
signals:
602597
void apiSupportsSubscriptionsChanged();
603598
void supportsSelectiveSyncChanged();

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)