mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 13:35:34 +08:00
refs #502, added role support and user as data object (for distribution)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
23b310ac9b
commit
87a55edc04
@@ -18,6 +18,9 @@ namespace BlackMisc
|
||||
{
|
||||
namespace Network
|
||||
{
|
||||
CAuthenticatedUser::CAuthenticatedUser()
|
||||
{ }
|
||||
|
||||
CAuthenticatedUser::CAuthenticatedUser(int id, const QString &realname)
|
||||
: IDatastoreObjectWithIntegerKey(id), m_realname(realname.trimmed())
|
||||
{ }
|
||||
@@ -87,6 +90,11 @@ namespace BlackMisc
|
||||
return this->hasRole("ADMIN");
|
||||
}
|
||||
|
||||
bool CAuthenticatedUser::isMappingAdmin() const
|
||||
{
|
||||
return this->hasRole("MAPPINGADMIN") || this->isAdmin();
|
||||
}
|
||||
|
||||
CIcon CAuthenticatedUser::toIcon() const
|
||||
{
|
||||
return CIconList::iconByIndex(CIcons::StandardIconUser16);
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace BlackMisc
|
||||
};
|
||||
|
||||
//! Default constructor.
|
||||
CAuthenticatedUser() = default;
|
||||
CAuthenticatedUser();
|
||||
|
||||
//! Constructor.
|
||||
CAuthenticatedUser(int id, const QString &realname);
|
||||
@@ -100,9 +100,12 @@ namespace BlackMisc
|
||||
//! Roles
|
||||
void setRoles(const CRoleList &roles) { m_roles = roles; }
|
||||
|
||||
//! Has roles?
|
||||
//! Has role?
|
||||
bool hasRole(const QString &roleName) const { return m_roles.hasRole(roleName); }
|
||||
|
||||
//! Has any role?
|
||||
bool hasAnyRole(const QStringList &roles) const { return m_roles.hasAnyRole(roles); }
|
||||
|
||||
//! Country
|
||||
const BlackMisc::CCountry &getCountry() const { return m_country; }
|
||||
|
||||
@@ -112,6 +115,9 @@ namespace BlackMisc
|
||||
//! Admin?
|
||||
bool isAdmin() const;
|
||||
|
||||
//! Admin?
|
||||
bool isMappingAdmin() const;
|
||||
|
||||
//! Authenticated
|
||||
void setAuthenticated(bool authenticated) { m_authenticated = authenticated; }
|
||||
|
||||
|
||||
@@ -25,6 +25,15 @@ namespace BlackMisc
|
||||
return hasRole(role.getName());
|
||||
}
|
||||
|
||||
bool CRoleList::hasAnyRole(const QStringList &roles) const
|
||||
{
|
||||
for (const QString &r : roles)
|
||||
{
|
||||
if (this->hasRole(r)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
CRoleList::CRoleList(const CSequence<CRole> &other) :
|
||||
CSequence<CRole>(other)
|
||||
{ }
|
||||
|
||||
@@ -38,6 +38,9 @@ namespace BlackMisc
|
||||
//! Has role?
|
||||
bool hasRole(const CRole &role) const;
|
||||
|
||||
//! Has any role?
|
||||
bool hasAnyRole(const QStringList &roles) const;
|
||||
|
||||
//! Construct from a base class object.
|
||||
CRoleList(const CSequence<CRole> &other);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user