Skip to content

Commit

Permalink
Hide email from dataset in boot script
Browse files Browse the repository at this point in the history
  • Loading branch information
minottic authored Apr 29, 2022
1 parent 78dcda4 commit f605aa9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/scicat-be.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
"MIDDLEWARE": $(jq -R -s < helm_configs/backend/${{ needs.set_env.outputs.environment }}/middleware.json),
"PUBLISH_FINISHED": $(jq -R -s < helm_configs/backend/publishWhenFinished.js),
"EMAIL_TEMPLATE": $(jq -R -s < helm_configs/backend/${{ needs.set_env.outputs.environment }}/job-tempate.html),
"HIDE_EMAIL": $(jq -R -s < helm_configs/backend/hideEmail.js),
}
EOF
)
Expand Down
24 changes: 24 additions & 0 deletions helm_configs/backend/hideEmail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use strict";

function hideEmails(result){
if(result.ownerEmail) result.ownerEmail="";
if(result.contactEmail) result.contactEmail="";
if(result.principalInvestigator) result.principalInvestigator="";
if(result.investigator) result.investigator="";
if(result.orcidOfOwner) result.orcidOfOwner="";
}

module.exports = function (app) {
app.models.Dataset.afterRemote("**",function(ctx, unused, next){
if(ctx.result) {
if(Array.isArray(ctx.result)) {
ctx.result.forEach(function (result) {
hideEmails(result);
});
} else {
hideEmails(ctx.result);
}
}
next();
});
}
6 changes: 5 additions & 1 deletion helm_configs/backend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ configMaps:
login-callbacks.js: "{{ .Values.ciVars.LOGIN_CALLBACKS }}"
middleware.json: "{{ .Values.ciVars.MIDDLEWARE }}"
publishWhenFinished.js: "{{ .Values.ciVars.PUBLISH_FINISHED }}"
job-tempate.html: "{{ .Values.ciVars.EMAIL_TEMPLATE }}"
job-tmpate.html: "{{ .Values.ciVars.EMAIL_TEMPLATE }}"
hideEmail.js: "{{ .Values.ciVars.HIDE_EMAIL }}"

env:
- name: ENV
Expand All @@ -89,6 +90,9 @@ volumeMounts:
- name: config-volume
mountPath: /usr/src/app/email-templates/job-tempate.html
subPath: job-tempate.html
- name: config-volume
mountPath: /usr/src/app/server/boot/hideEmail.js
subPath: hideEmail.js
- name: secrets-volume
mountPath: /usr/src/app/server/providers.json
subPath: providers.json
Expand Down

0 comments on commit f605aa9

Please sign in to comment.