Skip to content

Commit

Permalink
feat(api): add relationship to my-account in GET users/me
Browse files Browse the repository at this point in the history
  • Loading branch information
bpetetot authored Nov 20, 2024
1 parent 5780b54 commit 9c10594
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const userRoutes = [
handler: (request, h) => userController.getCurrentUserAccountInfo(request, h),
notes: [
'- **Cette route est restreinte aux utilisateurs authentifiés**\n' +
'- Récupération des information de compte utilisateur\n',
'- Récupération des informations du compte utilisateur authentifié\n',
],
tags: ['identity-access-management', 'api', 'user', 'my-account'],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const serialize = function (users, meta) {
'pixCertifTermsOfServiceAccepted',
'lang',
'isAnonymous',
'accountInfo',
'profile',
'hasSeenAssessmentInstructions',
'isCertifiable',
Expand Down Expand Up @@ -60,6 +61,12 @@ const serialize = function (users, meta) {
},
},
},
accountInfo: {
ref: 'id',
ignoreRelationshipData: true,
nullIfMissing: true,
relationshipLinks: { related: () => '/api/users/my-account' },
},
meta,
}).serialize(users);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,11 @@ describe('Acceptance | Identity Access Management | Application | Route | User',
'last-data-protection-policy-seen-at': null,
},
relationships: {
'account-info': {
links: {
related: '/api/users/my-account',
},
},
profile: {
links: {
related: `/api/users/${user.id}/profile`,
Expand Down Expand Up @@ -277,7 +282,7 @@ describe('Acceptance | Identity Access Management | Application | Route | User',
expect(response.statusCode).to.equal(200);
expect(response.result).to.deep.equal({
data: {
type: 'my-accounts',
type: 'account-infos',
id: user.id.toString(),
attributes: {
'can-self-delete-account': false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ describe('Unit | Identity Access Management | Infrastructure | Serializer | JSON
userModelObject.shouldSeeDataProtectionPolicyInformationBanner,
},
relationships: {
'account-info': {
links: {
related: '/api/users/my-account',
},
},
profile: {
links: {
related: `/api/users/${userModelObject.id}/profile`,
Expand Down

0 comments on commit 9c10594

Please sign in to comment.