Add "Request New Authorization"

Add reauthenticate to general authenticate dialog
This commit is contained in:
Magne Sjaastad 2025-02-14 15:47:26 +01:00
parent 860588d755
commit 45846ef39f
3 changed files with 30 additions and 9 deletions

View File

@ -247,11 +247,12 @@ void RiaCloudConnector::setTokenDataFilePath( const QString& filePath )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaCloudConnector::forceNewTokens()
void RiaCloudConnector::clearTokens()
{
if ( m_authCodeFlow )
{
m_authCodeFlow->grant();
m_authCodeFlow->setToken( "" );
m_authCodeFlow->setRefreshToken( "" );
}
}
@ -310,11 +311,23 @@ void RiaCloudConnector::requestTokenWithCancelButton()
QVBoxLayout* layout = new QVBoxLayout( &dialog );
QLabel* label = new QLabel( "Requesting token. Please wait..." );
QLabel* label =
new QLabel( "Requesting token.\nIf this process takes a long time,\nissue a new authentication process by pressing\n'New "
"Authentication'\n\n Please wait..." );
label->setAlignment( Qt::AlignHCenter );
layout->addWidget( label );
QPushButton* cancelButton = new QPushButton( "Cancel" );
layout->addWidget( cancelButton );
// Create horizontal button layout
QHBoxLayout* buttonLayout = new QHBoxLayout();
// Add buttons to horizontal layout
QPushButton* requestNewAuthenticationButton = new QPushButton( "New Authentication" );
QPushButton* cancelButton = new QPushButton( "Cancel" );
buttonLayout->addWidget( requestNewAuthenticationButton );
buttonLayout->addWidget( cancelButton );
// Add button layout to main layout
layout->addLayout( buttonLayout );
QTimer timer;
timer.setSingleShot( true );
@ -332,6 +345,14 @@ void RiaCloudConnector::requestTokenWithCancelButton()
loop.quit();
} );
connect( requestNewAuthenticationButton,
&QPushButton::clicked,
[&]()
{
clearTokens();
requestToken();
} );
connect( &dialog,
&QDialog::rejected,
[&]()

View File

@ -50,7 +50,7 @@ public:
QString requestTokenBlocking();
void requestTokenWithCancelButton();
void forceNewTokens();
void clearTokens();
bool isGranted() const;

View File

@ -202,6 +202,7 @@ void RimCloudDataSourceCollection::defineUiOrdering( QString uiConfigName, caf::
text += isGranted ? "<font color='#228B22'>✔ Granted</font>" : "<font color='#FFA500'>❌ Not Granted</font>";
m_authenticate.uiCapability()->setUiName( text );
m_authenticate.uiCapability()->setUiReadOnly( isGranted );
if ( isGranted )
{
@ -230,15 +231,14 @@ void RimCloudDataSourceCollection::defineEditorAttribute( const caf::PdmFieldHan
attrib->m_buttonText = "Authenticate";
}
}
if ( field == &m_addDataSources )
else if ( field == &m_addDataSources )
{
if ( auto attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute ) )
{
attrib->m_buttonText = "Add Data Sources(s)";
}
}
if ( field == &m_addEnsembles )
else if ( field == &m_addEnsembles )
{
if ( auto attrib = dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute ) )
{