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

BC-5566 - fix merlin feathers service #4480

Merged
merged 5 commits into from
Oct 19, 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
4 changes: 2 additions & 2 deletions src/services/edusharing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class EduSharingPlayer {
throw new MethodNotAllowed('This feature is disabled on this instance');
}
const esPlayer = EduSharingConnectorV7.getPlayerForNode(uuid);

return esPlayer;
}
}
Expand All @@ -49,7 +49,7 @@ class MerlinToken {
module.exports = (app) => {
const eduSharingRoute = '/edu-sharing';
const eduSharingPlayerRoute = '/edu-sharing/player';
const merlinRoute = '/edu-sharing/merlinToken';
const merlinRoute = '/edu-sharing-merlinToken';
const docRoute = '/edu-sharing/api';

app.use(eduSharingRoute, new EduSharing());
Expand Down
90 changes: 46 additions & 44 deletions src/services/lesson/hooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const convertMerlinUrl = async (context) => {
await Promise.all(
content.content.resources.map(async (resource) => {
if (resource && resource.merlinReference) {
resource.url = await context.app.service('edu-sharing/merlinToken').find({
resource.url = await context.app.service('edu-sharing-merlinToken').find({
...context.params,
query: { ...context.params.query, merlinReference: resource.merlinReference },
});
Expand All @@ -82,7 +82,7 @@ const convertMerlinUrl = async (context) => {
await Promise.all(
materialIds.map(async (material) => {
if (material.merlinReference) {
material.url = await context.app.service('edu-sharing/merlinToken').find({
material.url = await context.app.service('edu-sharing-merlinToken').find({
...context.params,
query: {
...context.params.query,
Expand Down Expand Up @@ -229,48 +229,50 @@ const populateWhitelist = {
],
};

exports.before = () => ({
all: [authenticate('jwt'), mapUsers],
find: [
hasPermission('TOPIC_VIEW'),
iff(isProvider('external'), validateLessonFind),
iff(isProvider('external'), getRestrictPopulatesHook(populateWhitelist)),
iff(isProvider('external'), restrictToUsersCoursesLessons),
],
get: [
hasPermission('TOPIC_VIEW'),
iff(isProvider('external'), getRestrictPopulatesHook(populateWhitelist)),
iff(isProvider('external'), restrictToUsersCoursesLessons),
],
create: [
checkIfCourseGroupLesson.bind(this, 'COURSEGROUP_CREATE', 'TOPIC_CREATE', true),
injectUserId,
checkCorrectCourseOrTeamId,
setPosition,
iff(isProvider('external'), preventPopulate),
],
update: [
iff(isProvider('external'), preventPopulate),
permitGroupOperation,
ifNotLocal(checkCorrectCourseOrTeamId),
iff(isProvider('external'), restrictToUsersCoursesLessons),
checkIfCourseGroupLesson.bind(this, 'COURSEGROUP_EDIT', 'TOPIC_EDIT', false),
],
patch: [
attachMerlinReferenceToLesson,
checkIfCourseGroupLesson.bind(this, 'COURSEGROUP_EDIT', 'TOPIC_EDIT', false),
permitGroupOperation,
ifNotLocal(checkCorrectCourseOrTeamId),
iff(isProvider('external'), restrictToUsersCoursesLessons),
iff(isProvider('external'), preventPopulate),
],
remove: [
checkIfCourseGroupLesson.bind(this, 'COURSEGROUP_CREATE', 'TOPIC_CREATE', false),
permitGroupOperation,
iff(isProvider('external'), restrictToUsersCoursesLessons),
iff(isProvider('external'), preventPopulate),
],
});
exports.before = () => {
return {
all: [authenticate('jwt'), mapUsers],
find: [
hasPermission('TOPIC_VIEW'),
iff(isProvider('external'), validateLessonFind),
iff(isProvider('external'), getRestrictPopulatesHook(populateWhitelist)),
iff(isProvider('external'), restrictToUsersCoursesLessons),
],
get: [
hasPermission('TOPIC_VIEW'),
iff(isProvider('external'), getRestrictPopulatesHook(populateWhitelist)),
iff(isProvider('external'), restrictToUsersCoursesLessons),
],
create: [
checkIfCourseGroupLesson.bind(this, 'COURSEGROUP_CREATE', 'TOPIC_CREATE', true),
injectUserId,
checkCorrectCourseOrTeamId,
setPosition,
iff(isProvider('external'), preventPopulate),
],
update: [
iff(isProvider('external'), preventPopulate),
permitGroupOperation,
ifNotLocal(checkCorrectCourseOrTeamId),
iff(isProvider('external'), restrictToUsersCoursesLessons),
checkIfCourseGroupLesson.bind(this, 'COURSEGROUP_EDIT', 'TOPIC_EDIT', false),
],
patch: [
attachMerlinReferenceToLesson,
checkIfCourseGroupLesson.bind(this, 'COURSEGROUP_EDIT', 'TOPIC_EDIT', false),
permitGroupOperation,
ifNotLocal(checkCorrectCourseOrTeamId),
iff(isProvider('external'), restrictToUsersCoursesLessons),
iff(isProvider('external'), preventPopulate),
],
remove: [
checkIfCourseGroupLesson.bind(this, 'COURSEGROUP_CREATE', 'TOPIC_CREATE', false),
permitGroupOperation,
iff(isProvider('external'), restrictToUsersCoursesLessons),
iff(isProvider('external'), preventPopulate),
],
};
};

exports.after = {
all: [],
Expand Down
2 changes: 1 addition & 1 deletion test/services/edusharing/services/merlinGenerator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Merlin Token Generator', () => {

before(async () => {
app = await appPromise();
MerlinTokenGeneratorService = app.service('edu-sharing/merlinToken');
MerlinTokenGeneratorService = app.service('edu-sharing-merlinToken');
server = await app.listen(0);
nestServices = await setupNestServices(app);
});
Expand Down
Loading