* Introduce isViewer field * Update policies * Make users read-only feature * Remove not demoting current user validation * Update tests * Catch the unhandled promise rejection * Hide unnecessary ui elements for read-only user * Update app/scenes/Settings/People.js Co-authored-by: Tom Moor <tom.moor@gmail.com> * Remove redundant logic for admin only policies * Use can logic * Update snapshot * Remove lint error * Update snapshot * Minor fix * Update app/menus/UserMenu.js Co-authored-by: Tom Moor <tom.moor@gmail.com> * Update server/api/users.js Co-authored-by: Tom Moor <tom.moor@gmail.com> * Update app/components/DocumentListItem.js Co-authored-by: Tom Moor <tom.moor@gmail.com> * Update app/stores/UsersStore.js Co-authored-by: Tom Moor <tom.moor@gmail.com> * Use useCurrentTeam hook in functional component * Update translation * Update ternary * Remove punctuation * Move the functions to User model * Update share policy and shareMenu * Rename makeAdmin to promote * Create updateCounts function and Rank enum * Update tests * Remove enum * Use async await, remove enum and create computed accessor * Remove unused variable * Fix lint issues * Hide templates * Create shared/types and use rank type from it * Delete shared/utils/rank type file Co-authored-by: Tom Moor <tom.moor@gmail.com>
272 lines
6.3 KiB
Plaintext
272 lines
6.3 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`#users.activate should activate a suspended user 1`] = `
|
|
Object {
|
|
"data": Object {
|
|
"avatarUrl": "https://tiley.herokuapp.com/avatar/111d68d06e2d317b5a59c2c6c5bad808/U.png",
|
|
"createdAt": "2018-01-02T00:00:00.000Z",
|
|
"email": "user1@example.com",
|
|
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
|
|
"isAdmin": false,
|
|
"isSuspended": false,
|
|
"isViewer": false,
|
|
"language": "en_US",
|
|
"lastActiveAt": null,
|
|
"name": "User 1",
|
|
},
|
|
"ok": true,
|
|
"policies": Array [
|
|
Object {
|
|
"abilities": Object {
|
|
"activate": true,
|
|
"delete": true,
|
|
"demote": true,
|
|
"promote": true,
|
|
"read": true,
|
|
"suspend": true,
|
|
"update": false,
|
|
},
|
|
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
|
|
},
|
|
],
|
|
"status": 200,
|
|
}
|
|
`;
|
|
|
|
exports[`#users.activate should require admin 1`] = `
|
|
Object {
|
|
"error": "admin_required",
|
|
"message": "An admin role is required to access this resource",
|
|
"ok": false,
|
|
"status": 403,
|
|
}
|
|
`;
|
|
|
|
exports[`#users.delete should require authentication 1`] = `
|
|
Object {
|
|
"error": "authentication_required",
|
|
"message": "Authentication required",
|
|
"ok": false,
|
|
"status": 401,
|
|
}
|
|
`;
|
|
|
|
exports[`#users.demote should demote an admin 1`] = `
|
|
Object {
|
|
"data": Object {
|
|
"avatarUrl": "https://tiley.herokuapp.com/avatar/111d68d06e2d317b5a59c2c6c5bad808/U.png",
|
|
"createdAt": "2018-01-02T00:00:00.000Z",
|
|
"email": "user1@example.com",
|
|
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
|
|
"isAdmin": false,
|
|
"isSuspended": false,
|
|
"isViewer": false,
|
|
"language": "en_US",
|
|
"lastActiveAt": null,
|
|
"name": "User 1",
|
|
},
|
|
"ok": true,
|
|
"policies": Array [
|
|
Object {
|
|
"abilities": Object {
|
|
"activate": true,
|
|
"delete": true,
|
|
"demote": true,
|
|
"promote": true,
|
|
"read": true,
|
|
"suspend": true,
|
|
"update": false,
|
|
},
|
|
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
|
|
},
|
|
],
|
|
"status": 200,
|
|
}
|
|
`;
|
|
|
|
exports[`#users.demote should demote an admin to viewer 1`] = `
|
|
Object {
|
|
"data": Object {
|
|
"avatarUrl": "https://tiley.herokuapp.com/avatar/111d68d06e2d317b5a59c2c6c5bad808/U.png",
|
|
"createdAt": "2018-01-02T00:00:00.000Z",
|
|
"email": "user1@example.com",
|
|
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
|
|
"isAdmin": false,
|
|
"isSuspended": false,
|
|
"isViewer": true,
|
|
"language": "en_US",
|
|
"lastActiveAt": null,
|
|
"name": "User 1",
|
|
},
|
|
"ok": true,
|
|
"policies": Array [
|
|
Object {
|
|
"abilities": Object {
|
|
"activate": true,
|
|
"delete": true,
|
|
"demote": true,
|
|
"promote": true,
|
|
"read": true,
|
|
"suspend": true,
|
|
"update": false,
|
|
},
|
|
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
|
|
},
|
|
],
|
|
"status": 200,
|
|
}
|
|
`;
|
|
|
|
exports[`#users.demote should demote an admin to member 1`] = `
|
|
Object {
|
|
"data": Object {
|
|
"avatarUrl": "https://tiley.herokuapp.com/avatar/111d68d06e2d317b5a59c2c6c5bad808/U.png",
|
|
"createdAt": "2018-01-02T00:00:00.000Z",
|
|
"email": "user1@example.com",
|
|
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
|
|
"isAdmin": false,
|
|
"isSuspended": false,
|
|
"isViewer": false,
|
|
"language": "en_US",
|
|
"lastActiveAt": null,
|
|
"name": "User 1",
|
|
},
|
|
"ok": true,
|
|
"policies": Array [
|
|
Object {
|
|
"abilities": Object {
|
|
"activate": true,
|
|
"delete": true,
|
|
"demote": true,
|
|
"promote": true,
|
|
"read": true,
|
|
"suspend": true,
|
|
"update": false,
|
|
},
|
|
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
|
|
},
|
|
],
|
|
"status": 200,
|
|
}
|
|
`;
|
|
|
|
exports[`#users.demote should not demote admins if only one available 1`] = `
|
|
Object {
|
|
"error": "validation_error",
|
|
"message": "At least one admin is required",
|
|
"ok": false,
|
|
"status": 400,
|
|
}
|
|
`;
|
|
|
|
exports[`#users.demote should require admin 1`] = `
|
|
Object {
|
|
"error": "admin_required",
|
|
"message": "An admin role is required to access this resource",
|
|
"ok": false,
|
|
"status": 403,
|
|
}
|
|
`;
|
|
|
|
exports[`#users.promote should promote a new admin 1`] = `
|
|
Object {
|
|
"data": Object {
|
|
"avatarUrl": "https://tiley.herokuapp.com/avatar/111d68d06e2d317b5a59c2c6c5bad808/U.png",
|
|
"createdAt": "2018-01-02T00:00:00.000Z",
|
|
"email": "user1@example.com",
|
|
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
|
|
"isAdmin": true,
|
|
"isSuspended": false,
|
|
"isViewer": false,
|
|
"language": "en_US",
|
|
"lastActiveAt": null,
|
|
"name": "User 1",
|
|
},
|
|
"ok": true,
|
|
"policies": Array [
|
|
Object {
|
|
"abilities": Object {
|
|
"activate": true,
|
|
"delete": true,
|
|
"demote": true,
|
|
"promote": false,
|
|
"read": true,
|
|
"suspend": true,
|
|
"update": false,
|
|
},
|
|
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
|
|
},
|
|
],
|
|
"status": 200,
|
|
}
|
|
`;
|
|
|
|
exports[`#users.promote should require admin 1`] = `
|
|
Object {
|
|
"error": "admin_required",
|
|
"message": "An admin role is required to access this resource",
|
|
"ok": false,
|
|
"status": 403,
|
|
}
|
|
`;
|
|
|
|
exports[`#users.suspend should not allow suspending the user themselves 1`] = `
|
|
Object {
|
|
"error": "validation_error",
|
|
"message": "Unable to suspend the current user",
|
|
"ok": false,
|
|
"status": 400,
|
|
}
|
|
`;
|
|
|
|
exports[`#users.suspend should require admin 1`] = `
|
|
Object {
|
|
"error": "admin_required",
|
|
"message": "An admin role is required to access this resource",
|
|
"ok": false,
|
|
"status": 403,
|
|
}
|
|
`;
|
|
|
|
exports[`#users.suspend should suspend an user 1`] = `
|
|
Object {
|
|
"data": Object {
|
|
"avatarUrl": "https://tiley.herokuapp.com/avatar/111d68d06e2d317b5a59c2c6c5bad808/U.png",
|
|
"createdAt": "2018-01-02T00:00:00.000Z",
|
|
"email": "user1@example.com",
|
|
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
|
|
"isAdmin": false,
|
|
"isSuspended": true,
|
|
"isViewer": false,
|
|
"language": "en_US",
|
|
"lastActiveAt": null,
|
|
"name": "User 1",
|
|
},
|
|
"ok": true,
|
|
"policies": Array [
|
|
Object {
|
|
"abilities": Object {
|
|
"activate": true,
|
|
"delete": true,
|
|
"demote": false,
|
|
"promote": false,
|
|
"read": true,
|
|
"suspend": true,
|
|
"update": false,
|
|
},
|
|
"id": "46fde1d4-0050-428f-9f0b-0bf77f4bdf61",
|
|
},
|
|
],
|
|
"status": 200,
|
|
}
|
|
`;
|
|
|
|
exports[`#users.update should require authentication 1`] = `
|
|
Object {
|
|
"error": "authentication_required",
|
|
"message": "Authentication required",
|
|
"ok": false,
|
|
"status": 401,
|
|
}
|
|
`;
|