Skip to content

Commit

Permalink
fix: deletedAt
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud AMBROSELLI committed Dec 7, 2023
1 parent 4d5f9b6 commit b508a01
Show file tree
Hide file tree
Showing 23 changed files with 61 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .kontinuous/env/prod/templates/dashboard.sealed-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ metadata:
spec:
encryptedData:
SENTRY_AUTH_TOKEN: AgCYmBko6+0bjL94Ok4xU0pQHeE8Ft45OzMHLlxOrK5bSXlwOK67SjFBlWLVcbnv8Hy8N+aUNRxMHD7dhD5yAyEDRWLTJUt6JojLP8f4OkX1hkt4nDI0pubzD5GRQTjLGnfS0mLHB5iIjbWc8gi2fnVx5TblhhmbbcPh8CEH12thKqFnI7TONLs3PVaieT2WTpWE8ZaxokngcERns/cEHJEuf6+744ee0QDgFNeaDxDWsrfcAUCHHo974QaYNhBI2qUxYXPnsiXyynS35f0HDJ3rVwtoQIwQYiM9YzD3BUMxK0evzGl6lciFEsq/69OK0PxFwClBndCyBVcThaKG4ikqgtQUZ1lW8QTdP8jN7k6sU/3sv9g+QkBqEc30YzVqbGjxpt1x5xIIjUu2Ub/NQ1T0KnC98I50DlN/48BWkoepDaWBGZEJ+5hPXwMQ9sF93jvBpF8dti/9Wv1dpcWxKqTNiPqosZ8A+Dt0nP/AVwxji7uLkXX7Df3KDZ0eLamEWO+Lth1a1D2IuYeYQoXk/H/XHvQxBEXKbOmx/g0KiuOMyl1c2pBT/R3A9GNasrV2dI3efcjsaopbtafsbDu5XvSsZt/1A3y4rGW6pEMYh4acr4WrF1X0EXT80n+jLSSCg0M7heMrbrChb4d680V5tPkMfvzNk6D8kVnK/QLmRp/FOjkF300/xR6+41TvbD3cg1z9ONY3N0rRoGp3nP5o1RPXYUQdBvGikOVA6dmUtY7X9SlB0J2MQTEctoabeW630D1vziZ6nV8/ozZn/eH017uu
REACT_APP_ORG_DUPLICATED_1_ID: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i28TTq5M/MW3zYqnmzX8Po67MFeDQ6s1pMF4orDsqFr2YN/KoX94VKEQvbi46241ojpkABgk2YHTCX5fWwI722Dy28fGeRTAU0v+HTFS+0e3NkL6NP1cWEIqrglhv61xzqTK5OVLl0WcPjv/ZuyZvf7D7gO3WKVZPCAFB8ayXbojhuEK0o11BIDFdGV6v5wbyeyZ7k+roZnqF/iHii7julSfii4S4V3WTDCZ3qPsqf19059xxhWnhNiDgPmL7XnPQEeAOh2iIR73mNsEGnvFVccMfx/UTZ61ST5aqgSPUjKqNIi/g+IzaEcqBajYdn6NP1DU8BWJezZVC6/DIu6XEB+a0iTLbt3S2f1gsw5q52tKNGPSfjGWptmQ6jlMZXo1l1C6SoXqI/8W2ojiuhpKWyxnUAG52IkF477PUKnX+kk7SE9qg2ploY14s/hMtrdSy9+wBzklMTH9zODFXn84LrYC/qNmbhEPjrBvBcYGZctUzH0B3C6m8lkSr2MuvKjr2eA8uSwqmdcYPZhF1+TN9/wnpmSRyZR/9F8Wk=
template:
metadata:
annotations:
Expand Down
15 changes: 15 additions & 0 deletions .kontinuous/env/prod/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,18 @@ jobs:
sentry_auth_token:
secretName: dashboard
secretKey: SENTRY_AUTH_TOKEN
react_app_org_duplicated_1_id:
secretName: dashboard
secretKey: REACT_APP_ORG_DUPLICATED_1_ID
react_app_org_duplicated_1_name:
secretName: dashboard
secretKey: REACT_APP_ORG_DUPLICATED_1_NAME
react_app_org_duplicated_2_id:
secretName: dashboard
secretKey: REACT_APP_ORG_DUPLICATED_2_ID
react_app_org_duplicated_2_name:
secretName: dashboard
secretKey: REACT_APP_ORG_DUPLICATED_2_NAME
react_app_org_id_for_truplication:
secretName: dashboard
secretKey: REACT_APP_ORG_ID_FOR_TRUPLICATION
1 change: 1 addition & 0 deletions api/src/controllers/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ router.put(
const password = crypto.randomBytes(60).toString("hex"); // A useless password.,
const forgotPasswordResetExpires = new Date(Date.now() + 60 * 60 * 24 * 30 * 1000); // 30 days
for (let item of newOrganisation.users) {
item.email = item.email.toLocaleLowerCase();
item.forgotPasswordResetToken = crypto.randomBytes(20).toString("hex");
item.forgotPasswordResetExpires = forgotPasswordResetExpires;
item.password = password;
Expand Down
21 changes: 20 additions & 1 deletion dashboard/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,26 @@ COPY --chown=1000:1000 dashboard/. .
ENV NODE_ENV=production

RUN --mount=type=secret,id=sentry_auth_token,uid=1000 \
yarn build; \
--mount=type=secret,id=react_app_org_duplicated_1_id,uid=1000 \
--mount=type=secret,id=react_app_org_duplicated_1_name,uid=1000 \
--mount=type=secret,id=react_app_org_duplicated_2_id,uid=1000 \
--mount=type=secret,id=react_app_org_duplicated_2_name,uid=1000 \
--mount=type=secret,id=react_app_org_id_for_truplication,uid=1000 \
if [ -f "/run/secrets/react_app_org_duplicated_1_id" ]; then \
export REACT_APP_ORG_ID_FOR_MIGRATION=$(cat /run/secrets/react_app_org_id_for_migration); \
fi; \
if [ -f "/run/secrets/react_app_org_duplicated_1_name" ]; then \
export REACT_APP_ORG_ID_FOR_MIGRATION=$(cat /run/secrets/react_app_org_id_for_migration); \
fi; \
if [ -f "/run/secrets/react_app_org_duplicated_2_id" ]; then \
export REACT_APP_ORG_ID_FOR_MIGRATION=$(cat /run/secrets/react_app_org_id_for_migration); \
fi; \
if [ -f "/run/secrets/react_app_org_duplicated_2_name" ]; then \
export REACT_APP_TEAM_1=$(cat /run/secrets/react_app_team_1); \
fi; \
if [ -f "/run/secrets/react_app_org_id_for_truplication" ]; then \
export REACT_APP_TEAM_2=$(cat /run/secrets/react_app_team_2); \
fi; \
if [ -f "/run/secrets/sentry_auth_token" ]; then \
export SENTRY_AUTH_TOKEN=$(cat /run/secrets/sentry_auth_token); \
yarn sentry:sourcemaps; \
Expand Down
6 changes: 2 additions & 4 deletions dashboard/src/components/DataMigrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ const duplicateDecryptedData = async ({
const personIdsMapped = {};
const newPersons = [];
for (const person of persons) {
const newPersonId = uuidv4();
personIdsMapped[person._id] = newPersonId;
if (!person.name && !person.deletedAt) {
continue;
}
const newPersonId = uuidv4();
personIdsMapped[person._id] = newPersonId;
const newPerson = {
...person,
user: userIdsMapped[person.user],
Expand Down Expand Up @@ -452,8 +452,6 @@ const duplicateDecryptedData = async ({
newReports.push(newReport);
}

const nextPersons = await Promise.all(newPersons.map(preparePersonForEncryption).map(encryptItem));

return {
organisationId: nextOrganisationId,
teams: newTeams,
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/recoil/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const prepareActionForEncryption = (action, { checkRequiredFields = true
organisation: action.organisation,
createdAt: action.createdAt,
updatedAt: action.updatedAt,
deletedAt: action.deletedAt,

completedAt: action.completedAt,
dueAt: action.dueAt,
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/recoil/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const prepareCommentForEncryption = (comment, { checkRequiredFields = tru
_id: comment._id,
createdAt: comment.createdAt,
updatedAt: comment.updatedAt,
deletedAt: comment.deletedAt,
organisation: comment.organisation,

decrypted,
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/recoil/consultations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export const prepareConsultationForEncryption =
organisation: consultation.organisation,
createdAt: consultation.createdAt,
updatedAt: consultation.updatedAt,
deletedAt: consultation.deletedAt,

completedAt: consultation.completedAt,
dueAt: consultation.dueAt,
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/recoil/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const prepareGroupForEncryption = (group: GroupInstance) => {
_id: group._id,
createdAt: group.createdAt,
updatedAt: group.updatedAt,
deletedAt: group.deletedAt,
organisation: group.organisation,

decrypted,
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/recoil/medicalFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const prepareMedicalFileForEncryption =
_id: medicalFile._id,
createdAt: medicalFile.createdAt,
updatedAt: medicalFile.updatedAt,
deletedAt: medicalFile.deletedAt,
organisation: medicalFile.organisation,

decrypted,
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/recoil/passages.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const preparePassageForEncryption = (passage, { checkRequiredFields = tru
_id: passage._id,
createdAt: passage.createdAt,
updatedAt: passage.updatedAt,
deletedAt: passage.deletedAt,
organisation: passage.organisation,

decrypted,
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/recoil/persons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export const usePreparePersonForEncryption = () => {
organisation: person.organisation,
createdAt: person.createdAt,
updatedAt: person.updatedAt,
deletedAt: person.deletedAt,
outOfActiveList: person.outOfActiveList,

decrypted,
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/recoil/places.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const preparePlaceForEncryption = (place, { checkRequiredFields = true }
_id: place._id,
createdAt: place.createdAt,
updatedAt: place.updatedAt,
deletedAt: place.deletedAt,
organisation: place.organisation,

decrypted,
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/recoil/relPersonPlace.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const prepareRelPersonPlaceForEncryption = (relPersonPlace, { checkRequir
_id: relPersonPlace._id,
createdAt: relPersonPlace.createdAt,
updatedAt: relPersonPlace.updatedAt,
deletedAt: relPersonPlace.deletedAt,
organisation: relPersonPlace.organisation,

decrypted,
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/recoil/rencontres.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const prepareRencontreForEncryption = (rencontre, { checkRequiredFields =
_id: rencontre._id,
createdAt: rencontre.createdAt,
updatedAt: rencontre.updatedAt,
deletedAt: rencontre.deletedAt,
organisation: rencontre.organisation,

decrypted,
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/recoil/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const prepareReportForEncryption = (report, { checkRequiredFields = true
_id: report._id,
createdAt: report.createdAt,
updatedAt: report.updatedAt,
deletedAt: report.deletedAt,
organisation: report.organisation,
date: report.date,
team: report.team,
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/recoil/territory.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const prepareTerritoryForEncryption = (territory, { checkRequiredFields =
_id: territory._id,
createdAt: territory.createdAt,
updatedAt: territory.updatedAt,
deletedAt: territory.deletedAt,
organisation: territory.organisation,

decrypted,
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/recoil/territoryObservations.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export const prepareObsForEncryption =
_id: obs._id,
createdAt: obs.createdAt,
updatedAt: obs.updatedAt,
deletedAt: obs.deletedAt,
organisation: obs.organisation,

decrypted,
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/recoil/treatments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const prepareTreatmentForEncryption = (treatment: TreatmentInstance, { ch
_id: treatment._id,
createdAt: treatment.createdAt,
updatedAt: treatment.updatedAt,
deletedAt: treatment.deletedAt,
organisation: treatment.organisation,

decrypted,
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/types/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface GroupInstance extends EncryptedGroupFields {
organisation: UUIDV4;
createdAt: Date;
updatedAt: Date;
deletedAt?: Date;
entityKey: string;
}

Expand Down
1 change: 1 addition & 0 deletions dashboard/src/types/medicalFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface MedicalFileInstance extends AdditionalProps {
comments: any[];
createdAt: Date;
updatedAt: Date;
deletedAt?: Date;
}

export interface NewMedicalFileInstance extends Omit<MedicalFileInstance, '_id' | 'createdAt' | 'updatedAt'> {}
1 change: 1 addition & 0 deletions dashboard/src/types/person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface PersonInstance {
organisation: UUIDV4;
createdAt: Date;
updatedAt: Date;
deletedAt?: Date;
outOfActiveList: boolean;
user: UUIDV4;
name: string;
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/types/treatment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export interface TreatmentInstance {
comments: any[];
createdAt: Date;
updatedAt: Date;
deletedAt?: Date;
history: any[];
}

0 comments on commit b508a01

Please sign in to comment.