Skip to content

Commit

Permalink
N21-2106 Fix oauth school feature (#3492)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinOehlerkingCap authored Jul 26, 2024
1 parent a1e7744 commit af4735c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
31 changes: 18 additions & 13 deletions controllers/administration.js
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ const getUsersWithoutConsent = async (req, roleName, classId) => {
.map((u) => u._id),
consentStatus: { $in: ['missing', 'parentsAgreed'] },
$limit: batchSize,
$sort: { 'lastName': 1},
$sort: { lastName: 1 },
},
})).data,
);
Expand Down Expand Up @@ -2260,6 +2260,8 @@ const schoolUpdateHandler = async (req, res, next) => {
name,
language,
logo_dataUrl,
rocketChat,
videoconference,
} = req.body;

let logo;
Expand All @@ -2270,14 +2272,28 @@ const schoolUpdateHandler = async (req, res, next) => {
};
}

const features = new Set(req.body.features);

if (rocketChat) {
features.add('rocketChat');
} else {
features.delete('rocketChat');
}

if (videoconference) {
features.add('videoconference');
} else {
features.delete('videoconference');
}

const requestBody = {
name,
language,
permissions: {
student: { LERNSTORE_VIEW: false },
teacher: { STUDENT_LIST: false },
},
features: [],
features: Array.from(features),
logo,
};

Expand All @@ -2293,17 +2309,6 @@ const schoolUpdateHandler = async (req, res, next) => {
requestBody.permissions.student.LERNSTORE_VIEW = !!req.body.studentlernstorevisibility;
}

// Update school features
const possibleSchoolFeatures = [
'messenger', 'messengerSchoolRoom', 'messengerStudentRoomCreate', 'rocketChat', 'videoconference',
];

for (const feature of possibleSchoolFeatures) {
if (req.body[feature] === 'true') {
requestBody.features.push(feature);
}
}

await api(req, { version: 'v3' }).patch(`/school/${res.locals.currentSchool}`, {
json: requestBody,
});
Expand Down
5 changes: 5 additions & 0 deletions views/administration/school.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@
</option>
{{/each}} </select> </div> {{/if}}
{{> "lib/components/csrfInput"}}

{{#each @root.school.features}}
<input type="hidden" name="features[]" value="{{this}}">
{{/each}}

<button type="submit" class="btn btn-primary btn-submit" data-testid="school-administration-save-general-setting">{{$t "administration.school.button.saveGeneralSettings" }}</button>
</form>

Expand Down

0 comments on commit af4735c

Please sign in to comment.