mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 12:35:43 +08:00
refs #485, renamed the trait for authenticated user to AuthenticatedDbUser
* there is no single authenticated user, this one has a specific usage * adjusted classed * formatting
This commit is contained in:
committed by
Mathew Sutcliffe
parent
f27d130df9
commit
55a0ab7b48
@@ -20,11 +20,12 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
namespace Data
|
namespace Data
|
||||||
{
|
{
|
||||||
//! Trait for for global setup data
|
//! Trait for for global cached DB user.
|
||||||
struct AuthenticatedUser : public BlackMisc::CDataTrait<BlackMisc::Network::CAuthenticatedUser>
|
//! This user has authenticated with the swift DB.
|
||||||
|
struct AuthenticatedDbUser : public BlackMisc::CDataTrait<BlackMisc::Network::CAuthenticatedUser>
|
||||||
{
|
{
|
||||||
//! Key in data cache
|
//! Key in data cache
|
||||||
static const char *key() { return "readers/global/user"; }
|
static const char *key() { return "dbuser"; }
|
||||||
|
|
||||||
//! Default value
|
//! Default value
|
||||||
static const BlackMisc::Network::CAuthenticatedUser &defaultValue()
|
static const BlackMisc::Network::CAuthenticatedUser &defaultValue()
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ namespace BlackCore
|
|||||||
url.setQuery("logoff=true");
|
url.setQuery("logoff=true");
|
||||||
QNetworkRequest request(CNetworkUtils::getNetworkRequest(url));
|
QNetworkRequest request(CNetworkUtils::getNetworkRequest(url));
|
||||||
sApp->getFromNetwork(request, { this, &CDatabaseAuthenticationService::ps_parseServerResponse });
|
sApp->getFromNetwork(request, { this, &CDatabaseAuthenticationService::ps_parseServerResponse });
|
||||||
this->m_user.set(CAuthenticatedUser());
|
this->m_swiftDbUser.set(CAuthenticatedUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDatabaseAuthenticationService::ps_parseServerResponse(QNetworkReply *nwReplyPtr)
|
void CDatabaseAuthenticationService::ps_parseServerResponse(QNetworkReply *nwReplyPtr)
|
||||||
@@ -124,7 +124,7 @@ namespace BlackCore
|
|||||||
msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "User has no roles"));
|
msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "User has no roles"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->m_user.set(user);
|
this->m_swiftDbUser.set(user);
|
||||||
emit userAuthenticationFinished(user, msgs);
|
emit userAuthenticationFinished(user, msgs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< data cache
|
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< data cache
|
||||||
BlackMisc::CData<BlackCore::Data::AuthenticatedUser> m_user {this, &CDatabaseAuthenticationService::ps_userChanged};
|
BlackMisc::CData<BlackCore::Data::AuthenticatedDbUser> m_swiftDbUser {this, &CDatabaseAuthenticationService::ps_userChanged};
|
||||||
bool m_shutdown = false;
|
bool m_shutdown = false;
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ namespace BlackGui
|
|||||||
void CDbMappingComponent::initVPilotLoading()
|
void CDbMappingComponent::initVPilotLoading()
|
||||||
{
|
{
|
||||||
bool canUseVPilot = true; // general flag if vPilot can be used/not used
|
bool canUseVPilot = true; // general flag if vPilot can be used/not used
|
||||||
this->m_withVPilot = canUseVPilot && this->m_user.get().isMappingAdmin();
|
this->m_withVPilot = canUseVPilot && this->m_swiftDbUser.get().isMappingAdmin();
|
||||||
static const QString tabName(this->ui->tw_ModelsToBeMapped->tabText(TabVPilot));
|
static const QString tabName(this->ui->tw_ModelsToBeMapped->tabText(TabVPilot));
|
||||||
|
|
||||||
if (this->m_vPilot1stInit && canUseVPilot)
|
if (this->m_vPilot1stInit && canUseVPilot)
|
||||||
|
|||||||
@@ -216,10 +216,10 @@ namespace BlackGui
|
|||||||
QScopedPointer<CDbAutoStashingComponent> m_autoStashDialog;
|
QScopedPointer<CDbAutoStashingComponent> m_autoStashDialog;
|
||||||
QScopedPointer<CDbModelMappingModifyComponent> m_modelModifyDialog;
|
QScopedPointer<CDbModelMappingModifyComponent> m_modelModifyDialog;
|
||||||
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules
|
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules
|
||||||
BlackMisc::CData<BlackCore::Data::VPilotAircraftModels> m_cachedVPilotModels { this, &CDbMappingComponent::ps_onVPilotCacheChanged }; //!< cache for latest vPilot rules
|
|
||||||
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models
|
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models
|
||||||
|
BlackMisc::CData<BlackCore::Data::VPilotAircraftModels> m_cachedVPilotModels { this, &CDbMappingComponent::ps_onVPilotCacheChanged }; //!< cache for latest vPilot rules
|
||||||
BlackMisc::CData<BlackCore::Data::OwnSimulatorAircraftModels> m_cachedOwnModels { this, &CDbMappingComponent::ps_ownModelsCacheChanged }; //!< cache for own installed models
|
BlackMisc::CData<BlackCore::Data::OwnSimulatorAircraftModels> m_cachedOwnModels { this, &CDbMappingComponent::ps_ownModelsCacheChanged }; //!< cache for own installed models
|
||||||
BlackMisc::CData<BlackCore::Data::AuthenticatedUser> m_user {this, &CDbMappingComponent::ps_userChanged};
|
BlackMisc::CData<BlackCore::Data::AuthenticatedDbUser> m_swiftDbUser {this, &CDbMappingComponent::ps_userChanged};
|
||||||
bool m_vPilot1stInit = true;
|
bool m_vPilot1stInit = true;
|
||||||
bool m_withVPilot = false;
|
bool m_withVPilot = false;
|
||||||
bool m_autoFilterInDbViews = false; //!< automatically filter the DB view by the current model
|
bool m_autoFilterInDbViews = false; //!< automatically filter the DB view by the current model
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ namespace BlackGui
|
|||||||
|
|
||||||
CForm::~CForm() { }
|
CForm::~CForm() { }
|
||||||
|
|
||||||
const BlackMisc::Network::CAuthenticatedUser &CForm::getUser() const
|
const BlackMisc::Network::CAuthenticatedUser &CForm::getSwiftDbUser() const
|
||||||
{
|
{
|
||||||
return this->m_user.get();
|
return this->m_swiftDbUser.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CForm::ps_userChanged()
|
void CForm::ps_userChanged()
|
||||||
|
|||||||
@@ -46,11 +46,11 @@ namespace BlackGui
|
|||||||
bool isReadOnly() const { return m_readOnly; }
|
bool isReadOnly() const { return m_readOnly; }
|
||||||
|
|
||||||
//! Authenticated user
|
//! Authenticated user
|
||||||
const BlackMisc::Network::CAuthenticatedUser &getUser() const;
|
const BlackMisc::Network::CAuthenticatedUser &getSwiftDbUser() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_readOnly = false; //!< read only
|
bool m_readOnly = false; //!< read only
|
||||||
BlackMisc::CData<BlackCore::Data::AuthenticatedUser> m_user {this, &CForm::ps_userChanged}; //!< authenticated user
|
BlackMisc::CData<BlackCore::Data::AuthenticatedDbUser> m_swiftDbUser {this, &CForm::ps_userChanged}; //!< authenticated user
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
//! User has been changed
|
//! User has been changed
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CModelMappingForm::ps_userChanged()
|
void CModelMappingForm::ps_userChanged()
|
||||||
{
|
{
|
||||||
const CAuthenticatedUser user(this->getUser());
|
const CAuthenticatedUser user(this->getSwiftDbUser());
|
||||||
if (user.isAdmin())
|
if (user.isAdmin())
|
||||||
{
|
{
|
||||||
ui->selector_ModelMode->setValue(CAircraftModel::Include);
|
ui->selector_ModelMode->setValue(CAircraftModel::Include);
|
||||||
|
|||||||
Reference in New Issue
Block a user