Skip to content

Commit

Permalink
feat(api): create GET /api/users/my-account endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
bpetetot authored Nov 20, 2024
1 parent a0a6f36 commit 5780b54
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
12 changes: 12 additions & 0 deletions api/src/identity-access-management/application/user/user.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ export const userRoutes = [
tags: ['identity-access-management', 'api', 'user'],
},
},
{
method: 'GET',
path: '/api/users/my-account',
config: {
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',
],
tags: ['identity-access-management', 'api', 'user', 'my-account'],
},
},
{
method: 'GET',
path: '/api/users/{id}/authentication-methods',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,35 @@ describe('Acceptance | Identity Access Management | Application | Route | User',
});
});

describe('GET /api/users/my-account', function () {
it('returns 200 HTTP status code', async function () {
// given
const user = databaseBuilder.factory.buildUser();
await databaseBuilder.commit();

// when
const response = await server.inject({
method: 'GET',
url: '/api/users/my-account',
headers: { authorization: generateValidRequestAuthorizationHeader(user.id) },
});

// then
expect(response.statusCode).to.equal(200);
expect(response.result).to.deep.equal({
data: {
type: 'my-accounts',
id: user.id.toString(),
attributes: {
'can-self-delete-account': false,
email: user.email,
username: user.username,
},
},
});
});
});

describe('GET /api/users/{id}/authentication-methods', function () {
it('returns 200 HTTP status code', async function () {
// given
Expand Down

0 comments on commit 5780b54

Please sign in to comment.