From 9ef0b84ad4bb6cd2526dd29a590079139eda7efe Mon Sep 17 00:00:00 2001 From: Mrika Llabani Date: Fri, 1 Sep 2023 14:29:19 +0200 Subject: [PATCH 1/5] N21-1235 remove seed data permissions --- backup/setup/roles.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backup/setup/roles.json b/backup/setup/roles.json index b605b90c55f..dc822d2c880 100644 --- a/backup/setup/roles.json +++ b/backup/setup/roles.json @@ -58,7 +58,6 @@ "TOOL_VIEW", "TOPIC_VIEW", "NEXTCLOUD_USER", - "JOIN_MEETING", "CONTEXT_TOOL_USER" ], "__v": 0 @@ -361,8 +360,7 @@ "CREATE_TOPICS_AND_TASKS", "EDIT_ALL_FILES", "NEWS_CREATE", - "START_MEETING", - "JOIN_MEETING" + "START_MEETING" ], "__v": 0 }, From 3aff1b14e8f0194c958bf5df5eead81f23ecb8f3 Mon Sep 17 00:00:00 2001 From: Mrika Llabani Date: Fri, 1 Sep 2023 15:11:43 +0200 Subject: [PATCH 2/5] N21-1235 add join vc permission to teacher --- backup/setup/roles.json | 5 +- ...-add-join-meeting-permission-to-teacher.js | 75 +++++++++++++++++++ 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 migrations/1693571501993-add-join-meeting-permission-to-teacher.js diff --git a/backup/setup/roles.json b/backup/setup/roles.json index dc822d2c880..253c6042eb4 100644 --- a/backup/setup/roles.json +++ b/backup/setup/roles.json @@ -196,7 +196,7 @@ }, "name": "teacher", "updatedAt": { - "$date": "2023-04-28T13:00:08.424Z" + "$date": "2023-09-01T13:09:20.214Z" }, "createdAt": { "$date": "2017-01-01T00:06:37.148Z" @@ -242,7 +242,8 @@ "START_MEETING", "HOMEWORK_CREATE", "HOMEWORK_EDIT", - "CONTEXT_TOOL_ADMIN" + "CONTEXT_TOOL_ADMIN", + "JOIN_MEETING" ], "__v": 2 }, diff --git a/migrations/1693571501993-add-join-meeting-permission-to-teacher.js b/migrations/1693571501993-add-join-meeting-permission-to-teacher.js new file mode 100644 index 00000000000..96f8c1f6288 --- /dev/null +++ b/migrations/1693571501993-add-join-meeting-permission-to-teacher.js @@ -0,0 +1,75 @@ +const mongoose = require('mongoose'); +// eslint-disable-next-line no-unused-vars +const { alert, error, info } = require('../src/logger'); + +const { connect, close } = require('../src/utils/database'); + +// use your own name for your model, otherwise other migrations may fail. +// The third parameter is the actually relevent one for what collection to write to. +const Roles = mongoose.model( + 'roles0109231450', + new mongoose.Schema( + { + name: { type: String, required: true }, + permissions: [{ type: String }], + }, + { + timestamps: true, + } + ), + 'roles' +); + +// How to use more than one schema per collection on mongodb +// https://stackoverflow.com/questions/14453864/use-more-than-one-schema-per-collection-on-mongodb + +// TODO npm run migration-persist and remove this line +// TODO update seed data and remove this line + +module.exports = { + up: async function up() { + // eslint-disable-next-line no-process-env + if (process.env.SC_THEME !== 'n21') { + info('Migration does not add the USER_LOGIN_MIGRATION_ADMIN permission for this instance.'); + return; + } + + await connect(); + + await Roles.updateOne( + { name: 'teacher' }, + { + $addToSet: { + permissions: { + $each: ['JOIN_MEETING'], + }, + }, + } + ).exec(); + alert(`Permission JOIN_MEETING added to role teacher`); + await close(); + }, + + down: async function down() { + // eslint-disable-next-line no-process-env + if (process.env.SC_THEME !== 'n21') { + info('Migration does not add the USER_LOGIN_MIGRATION_ADMIN permission for this instance.'); + return; + } + + await connect(); + + await Roles.updateOne( + { name: 'teacher' }, + { + $pull: { + permissions: { + $in: ['JOIN_MEETING'], + }, + }, + } + ).exec(); + alert(`Permisson JOIN_MEETING removed from role teacher`); + await close(); + }, +}; From 4d7e349c8d6b0673efb5d6faefe44501db921b04 Mon Sep 17 00:00:00 2001 From: Mrika Llabani Date: Fri, 1 Sep 2023 15:26:34 +0200 Subject: [PATCH 3/5] N21-1235 add start vc permission to admin --- backup/setup/roles.json | 7 +- ...-add-join-meeting-permission-to-teacher.js | 6 +- ...3-add-start-meeting-permission-to-admin.js | 75 +++++++++++++++++++ 3 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 migrations/1693574053453-add-start-meeting-permission-to-admin.js diff --git a/backup/setup/roles.json b/backup/setup/roles.json index 253c6042eb4..dace0c5560b 100644 --- a/backup/setup/roles.json +++ b/backup/setup/roles.json @@ -68,7 +68,7 @@ }, "name": "administrator", "updatedAt": { - "$date": "2023-05-16T08:17:53.317Z" + "$date": "2023-09-01T13:25:44.573Z" }, "createdAt": { "$date": "2017-01-01T00:06:37.148Z" @@ -130,7 +130,8 @@ "SYSTEM_CREATE", "SYSTEM_VIEW", "SCHOOL_TOOL_ADMIN", - "USER_LOGIN_MIGRATION_ADMIN" + "USER_LOGIN_MIGRATION_ADMIN", + "START_MEETING" ], "__v": 2 }, @@ -196,7 +197,7 @@ }, "name": "teacher", "updatedAt": { - "$date": "2023-09-01T13:09:20.214Z" + "$date": "2023-09-01T13:20:15.673Z" }, "createdAt": { "$date": "2017-01-01T00:06:37.148Z" diff --git a/migrations/1693571501993-add-join-meeting-permission-to-teacher.js b/migrations/1693571501993-add-join-meeting-permission-to-teacher.js index 96f8c1f6288..35a4d2bc37c 100644 --- a/migrations/1693571501993-add-join-meeting-permission-to-teacher.js +++ b/migrations/1693571501993-add-join-meeting-permission-to-teacher.js @@ -30,7 +30,7 @@ module.exports = { up: async function up() { // eslint-disable-next-line no-process-env if (process.env.SC_THEME !== 'n21') { - info('Migration does not add the USER_LOGIN_MIGRATION_ADMIN permission for this instance.'); + info('Migration does not add the JOIN_MEETING permission for this instance.'); return; } @@ -53,7 +53,7 @@ module.exports = { down: async function down() { // eslint-disable-next-line no-process-env if (process.env.SC_THEME !== 'n21') { - info('Migration does not add the USER_LOGIN_MIGRATION_ADMIN permission for this instance.'); + info('Migration does not add the JOIN_MEETING permission for this instance.'); return; } @@ -69,7 +69,7 @@ module.exports = { }, } ).exec(); - alert(`Permisson JOIN_MEETING removed from role teacher`); + alert(`Permission JOIN_MEETING removed from role teacher`); await close(); }, }; diff --git a/migrations/1693574053453-add-start-meeting-permission-to-admin.js b/migrations/1693574053453-add-start-meeting-permission-to-admin.js new file mode 100644 index 00000000000..4bdec238ca7 --- /dev/null +++ b/migrations/1693574053453-add-start-meeting-permission-to-admin.js @@ -0,0 +1,75 @@ +const mongoose = require('mongoose'); +// eslint-disable-next-line no-unused-vars +const { alert, error, info } = require('../src/logger'); + +const { connect, close } = require('../src/utils/database'); + +// use your own name for your model, otherwise other migrations may fail. +// The third parameter is the actually relevent one for what collection to write to. +const Roles = mongoose.model( + 'roles0109231514', + new mongoose.Schema( + { + name: { type: String, required: true }, + permissions: [{ type: String }], + }, + { + timestamps: true, + } + ), + 'roles' +); + +// How to use more than one schema per collection on mongodb +// https://stackoverflow.com/questions/14453864/use-more-than-one-schema-per-collection-on-mongodb + +// TODO npm run migration-persist and remove this line +// TODO update seed data and remove this line + +module.exports = { + up: async function up() { + // eslint-disable-next-line no-process-env + if (process.env.SC_THEME !== 'n21') { + info('Migration does not add the START_MEETING permission for this instance.'); + return; + } + + await connect(); + + await Roles.updateOne( + { name: 'administrator' }, + { + $addToSet: { + permissions: { + $each: ['START_MEETING'], + }, + }, + } + ).exec(); + alert(`Permission START_MEETING added to role administrator`); + await close(); + }, + + down: async function down() { + // eslint-disable-next-line no-process-env + if (process.env.SC_THEME !== 'n21') { + info('Migration does not add the START_MEETING permission for this instance.'); + return; + } + + await connect(); + + await Roles.updateOne( + { name: 'administrator' }, + { + $pull: { + permissions: { + $in: ['START_MEETING'], + }, + }, + } + ).exec(); + alert(`Permission START_MEETING removed from role administrator`); + await close(); + }, +}; From cef88b15c316fe2a8de10a423651f4002ec113d7 Mon Sep 17 00:00:00 2001 From: Mrika Llabani Date: Fri, 1 Sep 2023 15:36:34 +0200 Subject: [PATCH 4/5] N21-1235 add join vc permission to admin --- backup/setup/roles.json | 5 +- ...35-add-join-meeting-permission-to-admin.js | 75 +++++++++++++++++++ 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 migrations/1693574924835-add-join-meeting-permission-to-admin.js diff --git a/backup/setup/roles.json b/backup/setup/roles.json index dace0c5560b..2031ab8f801 100644 --- a/backup/setup/roles.json +++ b/backup/setup/roles.json @@ -68,7 +68,7 @@ }, "name": "administrator", "updatedAt": { - "$date": "2023-09-01T13:25:44.573Z" + "$date": "2023-09-01T13:35:21.524Z" }, "createdAt": { "$date": "2017-01-01T00:06:37.148Z" @@ -131,7 +131,8 @@ "SYSTEM_VIEW", "SCHOOL_TOOL_ADMIN", "USER_LOGIN_MIGRATION_ADMIN", - "START_MEETING" + "START_MEETING", + "JOIN_MEETING" ], "__v": 2 }, diff --git a/migrations/1693574924835-add-join-meeting-permission-to-admin.js b/migrations/1693574924835-add-join-meeting-permission-to-admin.js new file mode 100644 index 00000000000..9732d983bde --- /dev/null +++ b/migrations/1693574924835-add-join-meeting-permission-to-admin.js @@ -0,0 +1,75 @@ +const mongoose = require('mongoose'); +// eslint-disable-next-line no-unused-vars +const { alert, error, info } = require('../src/logger'); + +const { connect, close } = require('../src/utils/database'); + +// use your own name for your model, otherwise other migrations may fail. +// The third parameter is the actually relevent one for what collection to write to. +const Roles = mongoose.model( + 'roles0109231529', + new mongoose.Schema( + { + name: { type: String, required: true }, + permissions: [{ type: String }], + }, + { + timestamps: true, + } + ), + 'roles' +); + +// How to use more than one schema per collection on mongodb +// https://stackoverflow.com/questions/14453864/use-more-than-one-schema-per-collection-on-mongodb + +// TODO npm run migration-persist and remove this line +// TODO update seed data and remove this line + +module.exports = { + up: async function up() { + // eslint-disable-next-line no-process-env + if (process.env.SC_THEME !== 'n21') { + info('Migration does not add the JOIN_MEETING permission for this instance.'); + return; + } + + await connect(); + + await Roles.updateOne( + { name: 'administrator' }, + { + $addToSet: { + permissions: { + $each: ['JOIN_MEETING'], + }, + }, + } + ).exec(); + alert(`Permission JOIN_MEETING added to role administrator`); + await close(); + }, + + down: async function down() { + // eslint-disable-next-line no-process-env + if (process.env.SC_THEME !== 'n21') { + info('Migration does not add the JOIN_MEETING permission for this instance.'); + return; + } + + await connect(); + + await Roles.updateOne( + { name: 'administrator' }, + { + $pull: { + permissions: { + $in: ['JOIN_MEETING'], + }, + }, + } + ).exec(); + alert(`Permission JOIN_MEETING removed from role administrator`); + await close(); + }, +}; From 976731d295000efe4ab768b6c12491b32a11df76 Mon Sep 17 00:00:00 2001 From: Mrika Llabani Date: Mon, 4 Sep 2023 14:58:11 +0200 Subject: [PATCH 5/5] N21-1235 migration persist --- backup/setup/migrations.json | 33 +++++++++++++++++++ backup/setup/roles.json | 4 +-- ...-add-join-meeting-permission-to-teacher.js | 2 +- ...3-add-start-meeting-permission-to-admin.js | 2 +- ...35-add-join-meeting-permission-to-admin.js | 2 +- 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/backup/setup/migrations.json b/backup/setup/migrations.json index e8224045cae..96c0f276522 100644 --- a/backup/setup/migrations.json +++ b/backup/setup/migrations.json @@ -273,5 +273,38 @@ "$date": "2023-08-03T09:46:49.653Z" }, "__v": 0 + }, + { + "_id": { + "$oid": "64f1e7ce5f01dac16032e59d" + }, + "state": "up", + "name": "add-join-meeting-permission-to-admin", + "createdAt": { + "$date": "2023-09-01T13:28:44.835Z" + }, + "__v": 0 + }, + { + "_id": { + "$oid": "64f5c9d76edbcaa5cc4431d2" + }, + "state": "up", + "name": "add-join-meeting-permission-to-teacher", + "createdAt": { + "$date": "2023-09-01T12:31:41.993Z" + }, + "__v": 0 + }, + { + "_id": { + "$oid": "64f5c9d76edbcaa5cc4431d3" + }, + "state": "up", + "name": "add-start-meeting-permission-to-admin", + "createdAt": { + "$date": "2023-09-01T13:14:13.453Z" + }, + "__v": 0 } ] diff --git a/backup/setup/roles.json b/backup/setup/roles.json index 2031ab8f801..3d7909a84da 100644 --- a/backup/setup/roles.json +++ b/backup/setup/roles.json @@ -68,7 +68,7 @@ }, "name": "administrator", "updatedAt": { - "$date": "2023-09-01T13:35:21.524Z" + "$date": "2023-09-04T12:13:44.069Z" }, "createdAt": { "$date": "2017-01-01T00:06:37.148Z" @@ -198,7 +198,7 @@ }, "name": "teacher", "updatedAt": { - "$date": "2023-09-01T13:20:15.673Z" + "$date": "2023-09-04T12:54:47.237Z" }, "createdAt": { "$date": "2017-01-01T00:06:37.148Z" diff --git a/migrations/1693571501993-add-join-meeting-permission-to-teacher.js b/migrations/1693571501993-add-join-meeting-permission-to-teacher.js index 35a4d2bc37c..74118543ce8 100644 --- a/migrations/1693571501993-add-join-meeting-permission-to-teacher.js +++ b/migrations/1693571501993-add-join-meeting-permission-to-teacher.js @@ -53,7 +53,7 @@ module.exports = { down: async function down() { // eslint-disable-next-line no-process-env if (process.env.SC_THEME !== 'n21') { - info('Migration does not add the JOIN_MEETING permission for this instance.'); + info('Migration does not remove the JOIN_MEETING permission for this instance.'); return; } diff --git a/migrations/1693574053453-add-start-meeting-permission-to-admin.js b/migrations/1693574053453-add-start-meeting-permission-to-admin.js index 4bdec238ca7..4d45fe1cc0a 100644 --- a/migrations/1693574053453-add-start-meeting-permission-to-admin.js +++ b/migrations/1693574053453-add-start-meeting-permission-to-admin.js @@ -53,7 +53,7 @@ module.exports = { down: async function down() { // eslint-disable-next-line no-process-env if (process.env.SC_THEME !== 'n21') { - info('Migration does not add the START_MEETING permission for this instance.'); + info('Migration does not remove the START_MEETING permission for this instance.'); return; } diff --git a/migrations/1693574924835-add-join-meeting-permission-to-admin.js b/migrations/1693574924835-add-join-meeting-permission-to-admin.js index 9732d983bde..ea291b14405 100644 --- a/migrations/1693574924835-add-join-meeting-permission-to-admin.js +++ b/migrations/1693574924835-add-join-meeting-permission-to-admin.js @@ -53,7 +53,7 @@ module.exports = { down: async function down() { // eslint-disable-next-line no-process-env if (process.env.SC_THEME !== 'n21') { - info('Migration does not add the JOIN_MEETING permission for this instance.'); + info('Migration does not remove the JOIN_MEETING permission for this instance.'); return; }