Skip to content

Commit

Permalink
Fix incorrect missing authentication dialog trigger (#3703)
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorVieiraZ authored Feb 3, 2025
1 parent 50e7b68 commit f2d6780
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 2 additions & 4 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 @@ -3967,11 +3967,9 @@ DownloadQueueItem::DownloadQueueItem( const QString &fp, qint64 s, int v, qint64
void MerginApi::reloadProjectRole( const QString &projectFullName )
{
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
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 f2d6780

@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.2.701911 just submitted!

Please sign in to comment.