Minor fixes when reporting T141

* user authenticated must be enabled/valid
* Read only: BlackMisc::CDataReadOnly<BlackCore::Data::TAuthenticatedDbUser>
* clear user fields when not authenticated
This commit is contained in:
Klaus Basan
2017-08-27 23:01:39 +02:00
committed by Mathew Sutcliffe
parent 2dfc56dc39
commit 0dfe6f69fe
7 changed files with 13 additions and 9 deletions

View File

@@ -172,7 +172,7 @@ namespace BlackCore
void CDatabaseAuthenticationService::userChanged()
{
// code goes here
// this->logoff();
}
} // ns
} // ns

View File

@@ -155,6 +155,8 @@ namespace BlackGui
}
else
{
ui->le_Name->clear();
ui->te_Roles->clear();
this->setModeLogin(true);
}
}

View File

@@ -51,7 +51,7 @@ namespace BlackGui
private:
QScopedPointer<Ui::CDbLoginComponent> ui;
BlackCore::Db::CDatabaseAuthenticationService m_loginService {this}; //!< login service
BlackCore::Db::CDatabaseAuthenticationService m_loginService { this }; //!< login service
//! Overlay messages
void displayOverlayMessages(const BlackMisc::CStatusMessageList &msgs);

View File

@@ -135,9 +135,6 @@ namespace BlackGui
// vPilot
this->initVPilotLoading();
// user changes
m_swiftDbUser.setNotifySlot(&CDbMappingComponent::ps_userChanged);
}
CDbMappingComponent::~CDbMappingComponent()

View File

@@ -316,7 +316,7 @@ namespace BlackGui
QScopedPointer<CDbModelMappingModifyComponent> m_modelModifyDialog; //!< dialog when modifying models
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules
BlackMisc::CDigestSignal m_dsStashedModelsChanged { this, &CDbMappingComponent::ps_digestStashedModelsChanged, &CDbMappingComponent::ps_onStashedModelsChangedDigest, 750, 25 };
BlackMisc::CData<BlackCore::Data::TAuthenticatedDbUser> m_swiftDbUser { this };
BlackMisc::CDataReadOnly<BlackCore::Data::TAuthenticatedDbUser> m_swiftDbUser { this, &CDbMappingComponent::ps_userChanged };
const bool vPilotSupport = true; //!< vPilot support (will be removed in future)
bool m_vPilot1stInit = true; //!< vPilot extensions initalized?
bool m_vPilotEnabled = false; //!< use vPilot extensions

View File

@@ -117,6 +117,11 @@ namespace BlackMisc
return this->hasRole("BULKADD");
}
bool CAuthenticatedUser::isAuthenticated() const
{
return this->isEnabled() && this->isValid() && m_authenticated;
}
bool CAuthenticatedUser::canDirectlyWriteModels() const
{
return this->hasBulkRole() || this->hasBulkAddRole();
@@ -131,7 +136,7 @@ namespace BlackMisc
{
if (index.isMyself()) { return CVariant::from(*this); }
if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) { return IDatastoreObjectWithIntegerKey::propertyByIndex(index); }
ColumnIndex i = index.frontCasted<ColumnIndex>();
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexVatsimId:
@@ -153,7 +158,7 @@ namespace BlackMisc
{
if (index.isMyself()) { (*this) = variant.to<CAuthenticatedUser>(); return; }
if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) { IDatastoreObjectWithIntegerKey::setPropertyByIndex(index, variant); return; }
ColumnIndex i = index.frontCasted<ColumnIndex>();
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexVatsimId:

View File

@@ -144,7 +144,7 @@ namespace BlackMisc
void setAuthenticated(bool authenticated) { m_authenticated = authenticated; }
//! Authenticated
bool isAuthenticated() const { return m_authenticated; }
bool isAuthenticated() const;
//! Enabled
void setEnabled(bool enabled) { m_enabled = enabled; }