Skip to content

Commit

Permalink
BC-4938 - Add school specific Terms of Use for new school admin page (#…
Browse files Browse the repository at this point in the history
…4399)

* add new feature flag

* add correct database filename for consent version

* add params to get specific consent version type in registrationConsentService
  • Loading branch information
davwas authored Sep 13, 2023
1 parent 971b68e commit 718ccaf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions config/default.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,11 @@
"default": false,
"description": "Enables uploading of school specific Privacy Policy on new admin page."
},
"FEATURE_SCHOOL_TERMS_OF_USE_ENABLED": {
"type": "boolean",
"default": false,
"description": "Enables uploading of school specific Terms of Use on new admin page."
},
"ROCKETCHAT_SERVICE_ENABLED": {
"type": "boolean",
"default": false,
Expand Down
1 change: 1 addition & 0 deletions src/services/config/publicAppConfigService.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const exposedVars = [
'TEACHER_STUDENT_VISIBILITY__IS_ENABLED_BY_DEFAULT',
'TEACHER_STUDENT_VISIBILITY__IS_VISIBLE',
'FEATURE_SCHOOL_POLICY_ENABLED_NEW',
'FEATURE_SCHOOL_TERMS_OF_USE_ENABLED',
'FEATURE_VIDEOCONFERENCE_ENABLED',
'ROCKETCHAT_SERVICE_ENABLED',
'LERNSTORE_MODE',
Expand Down
5 changes: 3 additions & 2 deletions src/services/consent/services/consentVersionService.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ class ConsentVersionService {
}

createBase64File(consentDocumentData) {
const { schoolId, consentData } = consentDocumentData;
const { schoolId, consentData, consentTypes } = consentDocumentData;
if (consentData) {
const fileName = consentTypes[0].includes('terms') ? 'Terms of Use' : 'Privacy Policy';
return this.app.service('base64Files').create({
schoolId,
data: consentDocumentData.consentData,
filetype: 'pdf',
filename: 'Privacy Policy',
filename: fileName,
});
}
return Promise.resolve({});
Expand Down
9 changes: 7 additions & 2 deletions src/services/user/services/registrationConsent.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,20 @@ const registrationConsentServiceHooks = {
};

class RegistrationConsentService {
async get(importHash) {
async get(importHash, params) {
const consentType = params.query.consentType || 'privacy';
if (consentType !== 'privacy' && consentType !== 'termsOfUse') {
throw new BadRequest('Invalid Consent Type!');
}

const user = await this.importUserLinkService.get(importHash);
if (!user.userId) {
throw new BadRequest('Invalid Import Hash!');
}

const baseQuery = {
$limit: 1,
consentTypes: 'privacy',
consentTypes: [consentType],
$sort: {
updatedAt: -1,
},
Expand Down

0 comments on commit 718ccaf

Please sign in to comment.