Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove getUserRoles as an api call and add as decoded from the token #274

Merged
merged 2 commits into from
Nov 29, 2023

Conversation

thomasridd
Copy link
Contributor

What

  • Remove getUserRoles as an api call and get roles by decoding the token
  • Add roles to the getUser(token) service method
  • Update tests

Why

This significantly reduces the number of calls needed to external services. In this case the api method getUserRoles(token) merely sends the token off to the manage-users-api which decodes it and sends back the result.

@@ -28,10 +28,4 @@ export default class ManageUsersApiClient {
logger.info('Getting user details: calling HMPPS Manage Users Api')
return ManageUsersApiClient.restClient(token).get<User>({ path: '/users/me' })
}

getUserRoles(token: string): Promise<string[]> {
Copy link
Contributor

@andrewrlee andrewrlee Nov 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this not being used anywhere apart from tests?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apparently not

Copy link
Contributor

@andrewrlee andrewrlee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@andrewrlee andrewrlee merged commit b9a9f4b into main Nov 29, 2023
4 checks passed
@andrewrlee andrewrlee deleted the HAAR-2032-inspect-token-for-roles branch November 29, 2023 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants