mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +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
|
||||
{
|
||||
//! Trait for for global setup data
|
||||
struct AuthenticatedUser : public BlackMisc::CDataTrait<BlackMisc::Network::CAuthenticatedUser>
|
||||
//! Trait for for global cached DB user.
|
||||
//! This user has authenticated with the swift DB.
|
||||
struct AuthenticatedDbUser : public BlackMisc::CDataTrait<BlackMisc::Network::CAuthenticatedUser>
|
||||
{
|
||||
//! Key in data cache
|
||||
static const char *key() { return "readers/global/user"; }
|
||||
static const char *key() { return "dbuser"; }
|
||||
|
||||
//! Default value
|
||||
static const BlackMisc::Network::CAuthenticatedUser &defaultValue()
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace BlackCore
|
||||
url.setQuery("logoff=true");
|
||||
QNetworkRequest request(CNetworkUtils::getNetworkRequest(url));
|
||||
sApp->getFromNetwork(request, { this, &CDatabaseAuthenticationService::ps_parseServerResponse });
|
||||
this->m_user.set(CAuthenticatedUser());
|
||||
this->m_swiftDbUser.set(CAuthenticatedUser());
|
||||
}
|
||||
|
||||
void CDatabaseAuthenticationService::ps_parseServerResponse(QNetworkReply *nwReplyPtr)
|
||||
@@ -124,7 +124,7 @@ namespace BlackCore
|
||||
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);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -59,8 +59,8 @@ namespace BlackCore
|
||||
void ps_userChanged();
|
||||
|
||||
private:
|
||||
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::GlobalSetup> m_setup {this}; //!< data cache
|
||||
BlackMisc::CData<BlackCore::Data::AuthenticatedDbUser> m_swiftDbUser {this, &CDatabaseAuthenticationService::ps_userChanged};
|
||||
bool m_shutdown = false;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace BlackGui
|
||||
private:
|
||||
QScopedPointer<Ui::CDbLoginComponent> ui;
|
||||
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this, &CDbLoginComponent::ps_setupChanged}; //!< data cache
|
||||
BlackCore::CDatabaseAuthenticationService m_loginService {this}; //!< login service
|
||||
BlackCore::CDatabaseAuthenticationService m_loginService {this}; //!< login service
|
||||
|
||||
//! Overlay messages
|
||||
void displayOverlayMessages(const BlackMisc::CStatusMessageList &msgs);
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace BlackGui
|
||||
void CDbMappingComponent::initVPilotLoading()
|
||||
{
|
||||
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));
|
||||
|
||||
if (this->m_vPilot1stInit && canUseVPilot)
|
||||
|
||||
@@ -213,16 +213,16 @@ namespace BlackGui
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CDbMappingComponent> ui;
|
||||
QScopedPointer<CDbAutoStashingComponent> m_autoStashDialog;
|
||||
QScopedPointer<CDbModelMappingModifyComponent> m_modelModifyDialog;
|
||||
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules
|
||||
QScopedPointer<CDbAutoStashingComponent> m_autoStashDialog;
|
||||
QScopedPointer<CDbModelMappingModifyComponent> m_modelModifyDialog;
|
||||
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules
|
||||
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
|
||||
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft 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_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
|
||||
|
||||
//! Init vPilot if rights and suitable
|
||||
void initVPilotLoading();
|
||||
|
||||
@@ -19,9 +19,9 @@ namespace BlackGui
|
||||
|
||||
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()
|
||||
|
||||
@@ -46,11 +46,11 @@ namespace BlackGui
|
||||
bool isReadOnly() const { return m_readOnly; }
|
||||
|
||||
//! Authenticated user
|
||||
const BlackMisc::Network::CAuthenticatedUser &getUser() const;
|
||||
const BlackMisc::Network::CAuthenticatedUser &getSwiftDbUser() const;
|
||||
|
||||
protected:
|
||||
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:
|
||||
//! User has been changed
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace BlackGui
|
||||
|
||||
void CModelMappingForm::ps_userChanged()
|
||||
{
|
||||
const CAuthenticatedUser user(this->getUser());
|
||||
const CAuthenticatedUser user(this->getSwiftDbUser());
|
||||
if (user.isAdmin())
|
||||
{
|
||||
ui->selector_ModelMode->setValue(CAircraftModel::Include);
|
||||
|
||||
Reference in New Issue
Block a user