-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
87 lines (77 loc) · 1.5 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const BitSet = require('bitset');
const RIGHTS = [
'account_manage',
'account_manage_any',
'account_manage_password',
'access_loophole',
'rights_loophole',
'self_manage',
'site_manage',
'links_manage',
'activity_manage',
'help_manage',
'automation_manage',
'notify_manage',
'reseller_manage',
'connector_manage',
'ftp_access',
'sftp_access',
'dev_access',
'app_access',
'filehub_access',
'log_access',
'file_upload_limit',
'file_upload_exts',
'default_link_access',
];
const FEATURES = [
'newui',
'smb',
'activity',
'versioning',
'automation',
'ftp',
'newfs',
'logaccess',
'gdrive',
'connectoradmin',
'databasefs',
'filehubpaired',
'adminview',
'trashbin',
'ldap_sync',
'ldap_auth',
'custom_domain',
'trashbin_age',
'twofa',
'signatures',
'extended_activity',
'vue_ui',
];
function hasItem(name, bitmask, list) {
let success = false;
list.forEach((right, index) => {
if (right === name) {
success = Boolean(new BitSet(bitmask).get(index));
}
});
return success;
}
function hasFeature(name, bitmask) {
return hasItem(name, bitmask, FEATURES);
}
function hasFeatures(features, bitmask) {
return features.every((feature) => hasFeature(feature, bitmask));
}
function hasRight(name, bitmask) {
return hasItem(name, bitmask, RIGHTS);
}
function hasRights(rights, bitmask) {
return rights.every((right) => hasRight(right, bitmask));
}
module.exports = {
hasFeature,
hasFeatures,
hasRight,
hasRights,
};