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 b605b90c55f..3d7909a84da 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 @@ -69,7 +68,7 @@ }, "name": "administrator", "updatedAt": { - "$date": "2023-05-16T08:17:53.317Z" + "$date": "2023-09-04T12:13:44.069Z" }, "createdAt": { "$date": "2017-01-01T00:06:37.148Z" @@ -131,7 +130,9 @@ "SYSTEM_CREATE", "SYSTEM_VIEW", "SCHOOL_TOOL_ADMIN", - "USER_LOGIN_MIGRATION_ADMIN" + "USER_LOGIN_MIGRATION_ADMIN", + "START_MEETING", + "JOIN_MEETING" ], "__v": 2 }, @@ -197,7 +198,7 @@ }, "name": "teacher", "updatedAt": { - "$date": "2023-04-28T13:00:08.424Z" + "$date": "2023-09-04T12:54:47.237Z" }, "createdAt": { "$date": "2017-01-01T00:06:37.148Z" @@ -243,7 +244,8 @@ "START_MEETING", "HOMEWORK_CREATE", "HOMEWORK_EDIT", - "CONTEXT_TOOL_ADMIN" + "CONTEXT_TOOL_ADMIN", + "JOIN_MEETING" ], "__v": 2 }, @@ -361,8 +363,7 @@ "CREATE_TOPICS_AND_TASKS", "EDIT_ALL_FILES", "NEWS_CREATE", - "START_MEETING", - "JOIN_MEETING" + "START_MEETING" ], "__v": 0 }, 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..74118543ce8 --- /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 JOIN_MEETING 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 remove the JOIN_MEETING permission for this instance.'); + return; + } + + await connect(); + + await Roles.updateOne( + { name: 'teacher' }, + { + $pull: { + permissions: { + $in: ['JOIN_MEETING'], + }, + }, + } + ).exec(); + 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..4d45fe1cc0a --- /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 remove 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(); + }, +}; 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..ea291b14405 --- /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 remove 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(); + }, +};