From 08b91f43906cb800304a946fec64be8c52bcca7f Mon Sep 17 00:00:00 2001 From: Emmanuelle Bonnemay Date: Mon, 16 Dec 2024 14:45:17 +0100 Subject: [PATCH 1/3] feat(mon-pix): correct delete account message in es and nl. --- mon-pix/translations/es.json | 6 +++--- mon-pix/translations/nl.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mon-pix/translations/es.json b/mon-pix/translations/es.json index c9d10b3f289..2eb91be89d5 100644 --- a/mon-pix/translations/es.json +++ b/mon-pix/translations/es.json @@ -2162,8 +2162,8 @@ "more-information": "Para más información,", "more-information-contact-support": "puede ponerse en contacto con el servicio de asistencia.", "title": "Eliminar mi cuenta definitivamente", - "warning-email": "Esta acción es irreversible. {pixScore} Todas las habilidades, cursos y píxeles que haya obtenido se eliminarán de forma permanente para la cuenta PIX que utilice la dirección de correo electrónico{email}.", - "warning-other": "Esta acción es irreversible. {pixScore} Todas las habilidades, cursos y píxeles que haya obtenido se eliminarán permanentemente de la cuenta PIX.{firstName} {lastName}." + "warning-email": "Esta acción es irreversible. {pixScore} Todas las habilidades, cursos y píxeles que haya obtenido se eliminarán de forma permanente para la cuenta PIX que utilice la dirección de correo electrónico {email}.", + "warning-other": "Esta acción es irreversible. {pixScore} Todas las habilidades, cursos y píxeles que haya obtenido se eliminarán permanentemente de la cuenta PIX {firstName} {lastName}." }, "email-confirmed": "Dirección de correo electrónico verificada.", "email-verification": { @@ -2251,4 +2251,4 @@ "title": "Mis tutoriales" } } -} \ No newline at end of file +} diff --git a/mon-pix/translations/nl.json b/mon-pix/translations/nl.json index d9ec751dd47..a2981f7fabe 100644 --- a/mon-pix/translations/nl.json +++ b/mon-pix/translations/nl.json @@ -2162,8 +2162,8 @@ "more-information": "Voor meer informatie,", "more-information-contact-support": "kunt u contact opnemen met ondersteuning.", "title": "Mijn account permanent verwijderen", - "warning-email": "Deze actie is onomkeerbaar. {pixScore} Alle vaardigheden, cursussen en pix die je hebt verkregen worden permanent verwijderd voor het PIX-account met het e-mailadres{email}.", - "warning-other": "Deze actie is onomkeerbaar. {pixScore} Alle vaardigheden, cursussen en pix die je hebt behaald, worden permanent verwijderd van het PIX-account.{firstName} {lastName}." + "warning-email": "Deze actie is onomkeerbaar. {pixScore} Alle vaardigheden, cursussen en pix die je hebt verkregen worden permanent verwijderd voor het PIX-account met het e-mailadres {email}.", + "warning-other": "Deze actie is onomkeerbaar. {pixScore} Alle vaardigheden, cursussen en pix die je hebt behaald, worden permanent verwijderd van het PIX-account {firstName} {lastName}." }, "email-confirmed": "Geverifieerd e-mailadres.", "email-verification": { @@ -2251,4 +2251,4 @@ "title": "Mijn tutorials" } } -} \ No newline at end of file +} From bf37067c3fb517619bbdcadcde8185c1d5dd63bd Mon Sep 17 00:00:00 2001 From: Emmanuelle Bonnemay Date: Mon, 16 Dec 2024 20:22:48 +0100 Subject: [PATCH 2/3] feat(api): retrieve anonymisedById from user repository --- .../domain/models/UserDetailsForAdmin.js | 2 ++ .../infrastructure/repositories/user.repository.js | 1 + .../serializers/jsonapi/user-details-for-admin.serializer.js | 1 + .../acceptance/application/user/user.admin.route.test.js | 1 + .../jsonapi/user-details-for-admin.serializer.test.js | 1 + 5 files changed, 6 insertions(+) diff --git a/api/src/identity-access-management/domain/models/UserDetailsForAdmin.js b/api/src/identity-access-management/domain/models/UserDetailsForAdmin.js index 7ddbdd45f50..acfced3f1df 100644 --- a/api/src/identity-access-management/domain/models/UserDetailsForAdmin.js +++ b/api/src/identity-access-management/domain/models/UserDetailsForAdmin.js @@ -24,6 +24,7 @@ class UserDetailsForAdmin { emailConfirmedAt, userLogin, hasBeenAnonymised, + hasBeenAnonymisedBy, anonymisedByFirstName, anonymisedByLastName, isPixAgent, @@ -54,6 +55,7 @@ class UserDetailsForAdmin { this.emailConfirmedAt = emailConfirmedAt; this.userLogin = userLogin; this.hasBeenAnonymised = hasBeenAnonymised; + this.hasBeenAnonymisedBy = hasBeenAnonymisedBy; this.updatedAt = updatedAt; this.anonymisedByFirstName = anonymisedByFirstName; this.anonymisedByLastName = anonymisedByLastName; diff --git a/api/src/identity-access-management/infrastructure/repositories/user.repository.js b/api/src/identity-access-management/infrastructure/repositories/user.repository.js index 8b841407631..df1fa999f4d 100644 --- a/api/src/identity-access-management/infrastructure/repositories/user.repository.js +++ b/api/src/identity-access-management/infrastructure/repositories/user.repository.js @@ -557,6 +557,7 @@ function _fromKnexDTOToUserDetailsForAdmin({ authenticationMethods, userLogin, hasBeenAnonymised: userDTO.hasBeenAnonymised, + hasBeenAnonymisedBy: userDTO.hasBeenAnonymisedBy, updatedAt: userDTO.updatedAt, createdAt: userDTO.createdAt, anonymisedByFirstName: userDTO.anonymisedByFirstName, diff --git a/api/src/identity-access-management/infrastructure/serializers/jsonapi/user-details-for-admin.serializer.js b/api/src/identity-access-management/infrastructure/serializers/jsonapi/user-details-for-admin.serializer.js index 93102a52787..27107dbb3a1 100644 --- a/api/src/identity-access-management/infrastructure/serializers/jsonapi/user-details-for-admin.serializer.js +++ b/api/src/identity-access-management/infrastructure/serializers/jsonapi/user-details-for-admin.serializer.js @@ -30,6 +30,7 @@ const serialize = function (usersDetailsForAdmin) { 'lastLoggedAt', 'emailConfirmedAt', 'hasBeenAnonymised', + 'hasBeenAnonymisedBy', 'anonymisedByFullName', 'organizationLearners', 'authenticationMethods', diff --git a/api/tests/identity-access-management/acceptance/application/user/user.admin.route.test.js b/api/tests/identity-access-management/acceptance/application/user/user.admin.route.test.js index 4e30c1fc9e5..b4c6f5fe41a 100644 --- a/api/tests/identity-access-management/acceptance/application/user/user.admin.route.test.js +++ b/api/tests/identity-access-management/acceptance/application/user/user.admin.route.test.js @@ -288,6 +288,7 @@ describe('Acceptance | Identity Access Management | Application | Route | Admin 'pix-orga-terms-of-service-accepted': false, username: user.username, 'has-been-anonymised': false, + 'has-been-anonymised-by': null, 'anonymised-by-full-name': null, 'is-pix-agent': false, }); diff --git a/api/tests/identity-access-management/unit/infrastructure/serializers/jsonapi/user-details-for-admin.serializer.test.js b/api/tests/identity-access-management/unit/infrastructure/serializers/jsonapi/user-details-for-admin.serializer.test.js index f9d56538eec..d8a5f320308 100644 --- a/api/tests/identity-access-management/unit/infrastructure/serializers/jsonapi/user-details-for-admin.serializer.test.js +++ b/api/tests/identity-access-management/unit/infrastructure/serializers/jsonapi/user-details-for-admin.serializer.test.js @@ -47,6 +47,7 @@ describe('Unit | Serializer | JSONAPI | user-details-for-admin-serializer', func 'last-logged-at': now, 'email-confirmed-at': now, 'has-been-anonymised': false, + 'has-been-anonymised-by': null, 'anonymised-by-full-name': null, 'is-pix-agent': false, }, From 846427f1aa383593d9aa4ad9a26be7173b122ea7 Mon Sep 17 00:00:00 2001 From: Emmanuelle Bonnemay Date: Mon, 16 Dec 2024 20:26:36 +0100 Subject: [PATCH 3/3] feat(admin): display correct message in user overview when account is self deleted --- admin/app/components/users/user-overview.gjs | 11 ++- admin/app/models/user.js | 1 + .../components/users/user-overview-test.gjs | 77 ++++++++++++++++++- admin/translations/en.json | 9 ++- admin/translations/fr.json | 9 ++- 5 files changed, 98 insertions(+), 9 deletions(-) diff --git a/admin/app/components/users/user-overview.gjs b/admin/app/components/users/user-overview.gjs index 186cf38f015..8e26fbcf2b5 100644 --- a/admin/app/components/users/user-overview.gjs +++ b/admin/app/components/users/user-overview.gjs @@ -47,9 +47,14 @@ export default class UserOverview extends Component { } get anonymisationMessage() { - return this.args.user.anonymisedByFullName - ? `Utilisateur anonymisé par ${this.args.user.anonymisedByFullName}.` - : 'Utilisateur anonymisé.'; + if (this.args.user.id === String(this.args.user.hasBeenAnonymisedBy)) { + return this.intl.t('pages.user-details.overview.anonymisation.self-anonymisation-message'); + } + if (this.args.user.anonymisedByFullName) { + const fullName = this.args.user.anonymisedByFullName; + return this.intl.t('pages.user-details.overview.anonymisation.user-anonymised-by-admin-message', { fullName }); + } + return this.intl.t('pages.user-details.overview.anonymisation.default-anonymised-user-message'); } get canModifyEmail() { diff --git a/admin/app/models/user.js b/admin/app/models/user.js index 432cfe5b402..6ae3c18b726 100644 --- a/admin/app/models/user.js +++ b/admin/app/models/user.js @@ -19,6 +19,7 @@ export default class User extends Model { @attr() lastLoggedAt; @attr() emailConfirmedAt; @attr() hasBeenAnonymised; + @attr() hasBeenAnonymisedBy; @attr() anonymisedByFullName; @attr() isPixAgent; diff --git a/admin/tests/integration/components/users/user-overview-test.gjs b/admin/tests/integration/components/users/user-overview-test.gjs index f01ed04679e..ccf8c670f10 100644 --- a/admin/tests/integration/components/users/user-overview-test.gjs +++ b/admin/tests/integration/components/users/user-overview-test.gjs @@ -22,6 +22,65 @@ module('Integration | Component | users | user-overview', function (hooks) { }); module('when the admin look at user details', function () { + module('when the user is anonymised', function () { + module('when the user has self deleted his account', function () { + test('displays the dedicated deletion message', async function (assert) { + // given + + const store = this.owner.lookup('service:store'); + const user = store.createRecord('user', { + id: '123', + firstName: '(anonymised)', + lastName: '(anonymised)', + email: null, + username: null, + hasBeenAnonymised: true, + hasBeenAnonymisedBy: 123, + anonymisedByFullName: '(anonymised) (anonymised)', + }); + + // when + const screen = await render(); + + // then + assert + .dom(screen.getByText(t('pages.user-details.overview.anonymisation.self-anonymisation-message'))) + .exists(); + }); + }); + + module("when the user's account has been deleted by an admin member", function () { + test("displays the deletion message with the admin member's full name", async function (assert) { + // given + const store = this.owner.lookup('service:store'); + const fullName = 'Laurent Bobine'; + const user = store.createRecord('user', { + id: '123', + firstName: '(anonymised)', + lastName: '(anonymised)', + email: null, + username: null, + hasBeenAnonymised: true, + hasBeenAnonymisedBy: 456, + anonymisedByFullName: fullName, + }); + + // when + const screen = await render(); + + // then + + assert + .dom( + screen.getByText( + t('pages.user-details.overview.anonymisation.user-anonymised-by-admin-message', { fullName }), + ), + ) + .exists(); + }); + }); + }); + test('displays the update button', async function (assert) { // given const user = { @@ -545,19 +604,27 @@ module('Integration | Component | users | user-overview', function (hooks) { test('displays an anonymisation message with the full name of the admin member', async function (assert) { // given const store = this.owner.lookup('service:store'); - const user = store.createRecord('user', { hasBeenAnonymised: true, anonymisedByFullName: 'Laurent Gina' }); + const fullName = 'Laurent Gina'; + const user = store.createRecord('user', { hasBeenAnonymised: true, anonymisedByFullName: fullName }); // when const screen = await render(); // then - assert.dom(screen.getByText('Utilisateur anonymisé par Laurent Gina.')).exists(); + assert + .dom( + screen.getByText( + t('pages.user-details.overview.anonymisation.user-anonymised-by-admin-message', { fullName }), + ), + ) + .exists(); }); test('disables action buttons "Modifier" and "Anonymiser cet utilisateur"', async function (assert) { // given const store = this.owner.lookup('service:store'); - const user = store.createRecord('user', { hasBeenAnonymised: true, anonymisedByFullName: 'Laurent Gina' }); + const fullName = 'Laurent Gina'; + const user = store.createRecord('user', { hasBeenAnonymised: true, anonymisedByFullName: fullName }); // when const screen = await render(); @@ -577,7 +644,9 @@ module('Integration | Component | users | user-overview', function (hooks) { const screen = await render(); // then - assert.dom(screen.getByText('Utilisateur anonymisé.')).exists(); + assert + .dom(screen.getByText(t('pages.user-details.overview.anonymisation.default-anonymised-user-message'))) + .exists(); }); }); }); diff --git a/admin/translations/en.json b/admin/translations/en.json index 4b06830b69d..0632089eaf2 100644 --- a/admin/translations/en.json +++ b/admin/translations/en.json @@ -738,7 +738,7 @@ "authentication-methods": "Méthodes de connexion", "certification-centers-list": "Pix Certif", "cgu": "Terms of service", - "cgu-aria-label" : "Terms of service", + "cgu-aria-label": "Terms of service", "details": "Informations prescrit", "organizations-list": "Pix Orga", "participations-list": "Participations", @@ -753,6 +753,13 @@ "deactivate-certification-center-membership": "Le membre a correctement été désactivé.", "update-certification-center-membership-role": "Le rôle du membre a été modifié." } + }, + "overview": { + "anonymisation": { + "default-anonymised-user-message": "Anonymised user.", + "self-anonymisation-message": "User anonymised by themself.", + "user-anonymised-by-admin-message": "User anonymised by {fullName}." + } } }, "users-list": { diff --git a/admin/translations/fr.json b/admin/translations/fr.json index 4d88de3f23d..40b8f0dac05 100644 --- a/admin/translations/fr.json +++ b/admin/translations/fr.json @@ -762,7 +762,7 @@ "authentication-methods": "Méthodes de connexion", "certification-centers-list": "Pix Certif", "cgu": "CGU", - "cgu-aria-label" : "Conditions générales d'utilisation", + "cgu-aria-label": "Conditions générales d'utilisation", "details": "Informations prescrit", "organizations-list": "Pix Orga", "participations-list": "Participations", @@ -777,6 +777,13 @@ "deactivate-certification-center-membership": "Le membre a correctement été désactivé.", "update-certification-center-membership-role": "Le rôle du membre a été modifié." } + }, + "overview": { + "anonymisation": { + "default-anonymised-user-message": "Utilisateur anonymisé.", + "self-anonymisation-message": "Utilisateur anonymisé par lui-même.", + "user-anonymised-by-admin-message": "Utilisateur anonymisé par {fullName}." + } } }, "users-list": {