Some smaller fixes in prephase of T285

This commit is contained in:
Klaus Basan
2018-06-25 01:54:07 +02:00
parent 7bb6d84e93
commit 40582fcf59
6 changed files with 27 additions and 28 deletions

View File

@@ -45,14 +45,14 @@ namespace BlackCore
void CDatabaseAuthenticationService::gracefulShutdown()
{
if (this->m_shutdown) { return; }
this->m_shutdown = true;
if (m_shutdown) { return; }
m_shutdown = true;
this->logoff();
}
CAuthenticatedUser CDatabaseAuthenticationService::getDbUser() const
{
return this->m_swiftDbUser.get();
return m_swiftDbUser.get();
}
bool CDatabaseAuthenticationService::isUserAuthenticated() const
@@ -66,7 +66,7 @@ namespace BlackCore
CStatusMessageList msgs;
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation()}));
if (this->m_shutdown) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "Shutdown in progress")); return msgs; }
if (m_shutdown) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "Shutdown in progress")); return msgs; }
const QString un(username.trimmed());
const QString pw(password.trimmed());
@@ -87,7 +87,7 @@ namespace BlackCore
params.addQueryItem("password", pw);
if (sApp->getGlobalSetup().dbDebugFlag()) { CNetworkUtils::addDebugFlag(params); }
QString query = params.toString();
const QString query = params.toString();
const QNetworkRequest request(CNetworkUtils::getSwiftNetworkRequest(url, CNetworkUtils::PostUrlEncoded, sApp->getApplicationNameAndVersion()));
sApp->postToNetwork(request, CApplication::NoLogRequestId, query.toUtf8(), { this, &CDatabaseAuthenticationService::parseServerResponse});
static const QString rm("Sent request to authentication server '%1'");
@@ -101,7 +101,7 @@ namespace BlackCore
url.setQuery("logoff=true");
QNetworkRequest request(CNetworkUtils::getSwiftNetworkRequest(url));
sApp->getFromNetwork(request, { this, &CDatabaseAuthenticationService::parseServerResponse });
this->m_swiftDbUser.set(CAuthenticatedUser());
m_swiftDbUser.set(CAuthenticatedUser());
}
void CDatabaseAuthenticationService::parseServerResponse(QNetworkReply *nwReplyPtr)
@@ -109,12 +109,12 @@ namespace BlackCore
// always cleanup reply
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
if (this->m_shutdown) { return; }
if (m_shutdown) { return; }
QString urlString(nwReply->url().toString());
if (urlString.contains("logoff", Qt::CaseInsensitive))
{
sApp->deleteAllCookies();
emit logoffFinished();
emit this->logoffFinished();
return;
}
@@ -123,7 +123,7 @@ namespace BlackCore
const QString json(nwReply->readAll().trimmed());
if (json.isEmpty())
{
CLogMessage(this).error("Authentication failed, no response from %1") << urlString;
CLogMessage(this).error("Authentication failed, no response from '%1'") << urlString;
return;
}
if (!Json::looksLikeJson(json))
@@ -133,8 +133,8 @@ namespace BlackCore
}
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation()}));
QJsonObject jsonObj(Json::jsonObjectFromString(json));
CAuthenticatedUser user = CAuthenticatedUser::fromDatabaseJson(jsonObj.contains("user") ? jsonObj["user"].toObject() : jsonObj);
const QJsonObject jsonObj(Json::jsonObjectFromString(json));
const CAuthenticatedUser user = CAuthenticatedUser::fromDatabaseJson(jsonObj.contains("user") ? jsonObj["user"].toObject() : jsonObj);
CStatusMessageList msgs;
if (jsonObj.contains("messages"))
{
@@ -160,7 +160,7 @@ namespace BlackCore
msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "User has no roles"));
}
}
this->m_swiftDbUser.set(user);
m_swiftDbUser.set(user);
emit userAuthenticationFinished(user, msgs);
}
else

View File

@@ -45,7 +45,6 @@ namespace BlackCore
//! User authenticated
bool isUserAuthenticated() const;
public slots:
//! Try to login to authentication web service
BlackMisc::CStatusMessageList login(const QString &id, const QString &password);

View File

@@ -63,10 +63,10 @@ namespace BlackGui
ui->lbl_DatabaseName->setTextInteractionFlags(Qt::TextBrowserInteraction);
ui->lbl_DatabaseName->setOpenExternalLinks(true);
connect(ui->pb_Login, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLoginClicked);
connect(ui->pb_Logoff, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLogoffClicked);
connect(&m_loginService, &CDatabaseAuthenticationService::userAuthenticationFinished, this, &CDbLoginComponent::ps_authenticationFinished);
connect(ui->le_Password, &QLineEdit::returnPressed, this, &CDbLoginComponent::ps_onLoginClicked);
connect(ui->pb_Login, &QPushButton::clicked, this, &CDbLoginComponent::onLoginClicked);
connect(ui->pb_Logoff, &QPushButton::clicked, this, &CDbLoginComponent::onLogoffClicked);
connect(&m_loginService, &CDatabaseAuthenticationService::userAuthenticationFinished, this, &CDbLoginComponent::onAuthenticationFinished);
connect(ui->le_Password, &QLineEdit::returnPressed, this, &CDbLoginComponent::onLoginClicked);
// init GUI
this->setUserInfo(this->getDbUser());
@@ -77,12 +77,12 @@ namespace BlackGui
CAuthenticatedUser CDbLoginComponent::getDbUser() const
{
return this->m_loginService.getDbUser();
return m_loginService.getDbUser();
}
bool CDbLoginComponent::isUserAuthenticated() const
{
return this->m_loginService.isUserAuthenticated();
return m_loginService.isUserAuthenticated();
}
void CDbLoginComponent::displayOverlayMessages(const CStatusMessageList &msgs)
@@ -94,7 +94,7 @@ namespace BlackGui
mf->showOverlayMessages(msgs);
}
void CDbLoginComponent::ps_onLoginClicked()
void CDbLoginComponent::onLoginClicked()
{
const QString un(ui->le_Username->text().trimmed());
const QString pw(ui->le_Password->text().trimmed());
@@ -113,13 +113,13 @@ namespace BlackGui
this->showLoading(5000);
}
void CDbLoginComponent::ps_onLogoffClicked()
void CDbLoginComponent::onLogoffClicked()
{
this->m_loginService.logoff();
m_loginService.logoff();
this->setModeLogin(true);
}
void CDbLoginComponent::ps_authenticationFinished(const CAuthenticatedUser &user, const CStatusMessageList &statusMsgs)
void CDbLoginComponent::onAuthenticationFinished(const CAuthenticatedUser &user, const CStatusMessageList &statusMsgs)
{
this->hideLoading();
this->setUserInfo(user);

View File

@@ -62,15 +62,14 @@ namespace BlackGui
//! Set the user fields
void setUserInfo(const BlackMisc::Network::CAuthenticatedUser &user);
private slots:
//! Login
void ps_onLoginClicked();
void onLoginClicked();
//! Logoff
void ps_onLogoffClicked();
void onLogoffClicked();
//! User authentication completed
void ps_authenticationFinished(const BlackMisc::Network::CAuthenticatedUser &user, const BlackMisc::CStatusMessageList &statusMsgs);
void onAuthenticationFinished(const BlackMisc::Network::CAuthenticatedUser &user, const BlackMisc::CStatusMessageList &statusMsgs);
};
} // ns
} // ns

View File

@@ -919,6 +919,7 @@ namespace BlackGui
if (!m_updateSetting.get()) { return; }
QTimer::singleShot(delayedMs, this, [ = ]
{
if (!sGui || sGui->isShuttingDown()) { return; }
if (m_updateDialog) { return; }
this->checkNewVersion(true);
});

View File

@@ -193,7 +193,7 @@ void CSwiftData::displayLog()
void CSwiftData::checkMinimumVersion()
{
Q_ASSERT_X(sApp, Q_FUNC_INFO, "Need sApp");
if (!sApp || sApp->isShuttingDown()) { return; }
if (sApp->getGlobalSetup().isSwiftVersionMinimumMappingVersion())
{
CLogMessage(this).info("Checked mapping tool version, required '%1', this version '%2'") << sApp->getGlobalSetup().getMappingMinimumVersionString() << CBuildConfig::getVersionString();