mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
add 'write-to-user' permission & refactor checking for writeability
This commit is contained in:
parent
e327e80228
commit
7eeac66abf
6 changed files with 48 additions and 17 deletions
|
|
@ -12,7 +12,7 @@ Project::~Project() = default;
|
|||
|
||||
dv::value Project::serialize() const {
|
||||
auto permissionsList = dv::list();
|
||||
for (const auto& perm : permissions) {
|
||||
for (const auto& perm : permissions.permissions) {
|
||||
permissionsList.add(perm);
|
||||
}
|
||||
return dv::object({
|
||||
|
|
@ -31,10 +31,11 @@ void Project::deserialize(const dv::value& src) {
|
|||
if (src.has("permissions")) {
|
||||
std::vector<std::string> perms;
|
||||
dv::get(src, "permissions", perms);
|
||||
permissions = std::set<std::string>(perms.begin(), perms.end());
|
||||
permissions.permissions =
|
||||
std::set<std::string>(perms.begin(), perms.end());
|
||||
}
|
||||
logger.info() << "permissions: ";
|
||||
for (const auto& perm : permissions) {
|
||||
for (const auto& perm : permissions.permissions) {
|
||||
logger.info() << " - " << perm;
|
||||
}
|
||||
}
|
||||
|
|
@ -58,3 +59,7 @@ void Project::loadProjectStartScript() {
|
|||
logger.warning() << "project start script does not exists";
|
||||
}
|
||||
}
|
||||
|
||||
bool Permissions::has(const std::string& name) const {
|
||||
return permissions.find(name) != permissions.end();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,13 +12,21 @@ namespace scripting {
|
|||
class IClientProjectScript;
|
||||
}
|
||||
|
||||
struct Permissions {
|
||||
static inline std::string WRITE_TO_USER = "write-to-user";
|
||||
|
||||
std::set<std::string> permissions;
|
||||
|
||||
bool has(const std::string& name) const;
|
||||
};
|
||||
|
||||
struct Project : Serializable {
|
||||
std::string name;
|
||||
std::string title;
|
||||
std::vector<std::string> basePacks;
|
||||
std::unique_ptr<scripting::IClientProjectScript> clientScript;
|
||||
std::unique_ptr<Process> setupCoroutine;
|
||||
std::set<std::string> permissions;
|
||||
Permissions permissions;
|
||||
|
||||
~Project();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue