Skip to content

Commit

Permalink
last update
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorVieiraZ committed Jan 29, 2025
1 parent 00ca4d1 commit 2697960
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
13 changes: 3 additions & 10 deletions core/merginapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@ bool MerginApi::validateAuth()
return false;
}

if ( mUserAuth->authToken().isEmpty() || mUserAuth->tokenExpiration() < QDateTime().currentDateTime().toUTC() )
if ( mUserAuth->authToken().isEmpty() || mUserAuth->tokenExpiration() < QDateTime().currentDateTimeUtc() )
{
authorize( mUserAuth->username(), mUserAuth->password() );
CoreUtils::log( QStringLiteral( "MerginApi" ), QStringLiteral( "Requesting authorization because of missing or expired token." ) );
Expand Down Expand Up @@ -3966,12 +3966,10 @@ DownloadQueueItem::DownloadQueueItem( const QString &fp, qint64 s, int v, qint64

void MerginApi::reloadProjectRole( const QString &projectFullName )
{
if ( projectFullName.isEmpty() || !isLoggedIn() )
{
if ( projectFullName.isEmpty() )
return;
}

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

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

emit networkManagerChanged();
}

bool MerginApi::isLoggedIn() const
{
return mUserAuth->hasAuthData() && !mUserAuth->authToken().isEmpty() && !( mUserAuth->tokenExpiration() < QDateTime().currentDateTime().toUTC() );
}
5 changes: 0 additions & 5 deletions core/merginapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -593,11 +593,6 @@ class MerginApi: public QObject
*/
void setNetworkManager( QNetworkAccessManager *manager );

/**
* Returns whether user is currently logged in
*/
Q_INVOKABLE bool isLoggedIn() const;

signals:
void apiSupportsSubscriptionsChanged();
void supportsSelectiveSyncChanged();
Expand Down
5 changes: 5 additions & 0 deletions core/merginuserauth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,8 @@ bool MerginUserAuth::hasValidToken() const
{
return !mAuthToken.isEmpty() && mTokenExpiration >= QDateTime().currentDateTimeUtc();
}

bool MerginUserAuth::isLoggedIn()
{
return hasAuthData() && hasValidToken();
}
5 changes: 5 additions & 0 deletions core/merginuserauth.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class MerginUserAuth: public QObject
//! i.e. we should be good to do authenticated requests.
Q_INVOKABLE bool hasValidToken() const;

/**
* Returns whether user is currently logged in
*/
Q_INVOKABLE bool isLoggedIn();

void clear();

QString username() const;
Expand Down

1 comment on commit 2697960

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 25.1.701211 just submitted!

Please sign in to comment.