nodejs: user role

This commit is contained in:
Sergey Linnik
2025-03-14 14:02:43 +03:00
parent f83b4a8be8
commit a2088ae8e1
4 changed files with 16 additions and 2 deletions

View File

@ -1,5 +1,7 @@
# Change Log # Change Log
- nodejs: user role
## 1.12.0 ## 1.12.0
- nodejs: refresh config - nodejs: refresh config
- nodejs: support pages, numbers, key formats - nodejs: support pages, numbers, key formats

View File

@ -1124,6 +1124,7 @@ app.get('/editor', (req, res) => { // define a handler for editing document
const { reviewGroups } = user; const { reviewGroups } = user;
const { commentGroups } = user; const { commentGroups } = user;
const { userInfoGroups } = user; const { userInfoGroups } = user;
const userRoles = user.roles;
const usersInfo = []; const usersInfo = [];
const usersForProtect = []; const usersForProtect = [];
@ -1211,6 +1212,7 @@ app.get('/editor', (req, res) => { // define a handler for editing document
userImage: user.avatar ? `${req.DocManager.getServerUrl()}/images/${user.id}.png` : null, userImage: user.avatar ? `${req.DocManager.getServerUrl()}/images/${user.id}.png` : null,
name, name,
userGroup, userGroup,
userRoles,
reviewGroups: JSON.stringify(reviewGroups), reviewGroups: JSON.stringify(reviewGroups),
commentGroups: JSON.stringify(commentGroups), commentGroups: JSON.stringify(commentGroups),
userInfoGroups: JSON.stringify(userInfoGroups), userInfoGroups: JSON.stringify(userInfoGroups),

View File

@ -33,6 +33,7 @@ class User {
goback, goback,
close, close,
canSubmitForm, canSubmitForm,
roles,
) { ) {
this.id = id; this.id = id;
this.name = name; this.name = name;
@ -49,6 +50,7 @@ class User {
this.goback = goback; this.goback = goback;
this.close = close; this.close = close;
this.canSubmitForm = canSubmitForm; this.canSubmitForm = canSubmitForm;
this.roles = roles;
} }
} }
@ -62,6 +64,7 @@ const descrUser1 = [
'Can see the information about all users', 'Can see the information about all users',
'Can submit forms', 'Can submit forms',
'Has an avatar', 'Has an avatar',
'Has no roles',
]; ];
const descrUser2 = [ const descrUser2 = [
@ -73,6 +76,7 @@ const descrUser2 = [
'Can see the information about users from Group2 and users who dont belong to any group', 'Can see the information about users from Group2 and users who dont belong to any group',
'Can submit forms', 'Can submit forms',
'Has an avatar', 'Has an avatar',
'Has role "Anyone"',
]; ];
const descrUser3 = [ const descrUser3 = [
@ -88,6 +92,7 @@ const descrUser3 = [
'Cant submit forms', 'Cant submit forms',
'Cant close history', 'Cant close history',
'Cant restore the file version', 'Cant restore the file version',
'Has role "role"',
]; ];
const descrUser0 = [ const descrUser0 = [
@ -105,6 +110,7 @@ const descrUser0 = [
'View file without collaboration', 'View file without collaboration',
'Cant submit forms', 'Cant submit forms',
'Cant refresh outdated file', 'Cant refresh outdated file',
'Has empty role',
]; ];
const users = [ const users = [
@ -124,6 +130,7 @@ const users = [
{ blank: false }, { blank: false },
{ visible: false }, { visible: false },
true, true,
null,
), ),
new User( new User(
'uid-2', 'uid-2',
@ -145,6 +152,7 @@ const users = [
{ text: 'Go to Documents' }, { text: 'Go to Documents' },
{}, {},
true, true,
[ 'Anyone' ],
), ),
new User( new User(
'uid-3', 'uid-3',
@ -166,8 +174,9 @@ const users = [
null, null,
{}, {},
false, false,
[ 'role' ],
), ),
new User('uid-0', null, null, null, null, {}, [], null, ['protect'], descrUser0, false, false, null, null, false), new User('uid-0', null, null, null, null, {}, [], null, ['protect'], descrUser0, false, false, null, null, false, []),
]; ];
// get a list of all the users // get a list of all the users

View File

@ -60,7 +60,8 @@
"group": "<%- editor.userGroup %>", "group": "<%- editor.userGroup %>",
"id": "<%- editor.userid %>", "id": "<%- editor.userid %>",
"image": "<%- editor.userImage %>", "image": "<%- editor.userImage %>",
"name": "<%- editor.name %>" "name": "<%- editor.name %>",
"roles": <%- JSON.stringify(editor.userRoles) %>
} }
}, },
"height": "100%", "height": "100%",