Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N21 1235 vc permission in ctl bug fix #4376

Merged
merged 6 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions backup/setup/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
15 changes: 8 additions & 7 deletions backup/setup/roles.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
"TOOL_VIEW",
"TOPIC_VIEW",
"NEXTCLOUD_USER",
"JOIN_MEETING",
"CONTEXT_TOOL_USER"
],
"__v": 0
Expand All @@ -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"
Expand Down Expand Up @@ -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
},
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -243,7 +244,8 @@
"START_MEETING",
"HOMEWORK_CREATE",
"HOMEWORK_EDIT",
"CONTEXT_TOOL_ADMIN"
"CONTEXT_TOOL_ADMIN",
"JOIN_MEETING"
],
"__v": 2
},
Expand Down Expand Up @@ -361,8 +363,7 @@
"CREATE_TOPICS_AND_TASKS",
"EDIT_ALL_FILES",
"NEWS_CREATE",
"START_MEETING",
"JOIN_MEETING"
"START_MEETING"
],
"__v": 0
},
Expand Down
75 changes: 75 additions & 0 deletions migrations/1693571501993-add-join-meeting-permission-to-teacher.js
Original file line number Diff line number Diff line change
@@ -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();
},
};
75 changes: 75 additions & 0 deletions migrations/1693574053453-add-start-meeting-permission-to-admin.js
Original file line number Diff line number Diff line change
@@ -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();
},
};
75 changes: 75 additions & 0 deletions migrations/1693574924835-add-join-meeting-permission-to-admin.js
Original file line number Diff line number Diff line change
@@ -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();
},
};
Loading