8000 (bugfix) LANDGRIF-1210 - Fix update user roles by alexeh · Pull Request #905 · Vizzuality/landgriffon · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

(bugfix) LANDGRIF-1210 - Fix update user roles #905

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

Merged
merged 1 commit into from
Mar 7, 2023

Conversation

alexeh
Copy link
Collaborator
@alexeh alexeh commented Mar 6, 2023

General description

This PR fixes a bug where roles where not updating for a user.

The roles are sent as a array of strings which has to be converted to a proper entity before saving them to the database.

Using a basic update statement by typeorm repository, the entity will get updated by the values that matches the entity, and it will return the same DTO that has consumed, meaning that, during updating, the array of strings roles will be ignored, but it will be returned

Designs

Link to the related design prototypes (if applicable)

Testing instructions

Given a admin role, update any users roles via PATCH /user.
It will return the roles as entities in the role property in the user object, plus some permissions associated. if any role has any

Checklist before merging

  • Branch name / PR includes the related Jira ticket Id.
  • Tests to check core implementation / bug fix added.
  • All checks in Continuous Integration workflow pass.
  • Feature functionally tested by reviewer(s).
  • Code reviewed by reviewer(s).
  • Documentation updated (README, CHANGELOG...) (if required)

@vercel
Copy link
vercel bot commented Mar 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated
landgriffon-client ⬜️ Ignored (Inspect) Mar 7, 2023 at 0:54AM (UTC)
landgriffon-cookie-traceability ⬜️ Ignored (Inspect) Mar 7, 2023 at 0:54AM (UTC)

@alexeh alexeh marked this pull request as ready for review March 6, 2023 08:19
@alexeh alexeh requested review from KevSanchez and yulia-bel March 6, 2023 08:19
@alexeh alexeh force-pushed the bugix/update-user-roles branch from fde12de to 8aede6b Compare March 6, 2023 08:21
@alexeh alexeh changed the title Fix update user roles (bugfix) LANDGRIF-1210 - Fix update user roles Mar 6, 2023
@@ -183,4 +183,17 @@ export class UsersService extends AppBaseService<
async deleteUser(userId: string): Promise<DeleteResult> {
return this.repository.delete(userId);
}

async updateUser(userId: string, updateUser: any): Promise<User> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

set correct typing

@@ -282,4 +284,8 @@ export class AuthenticationService {
throw new ConflictException('Email already exists.');
}
}

updateRoles(rolesEnum: ROLES[]): Role[] {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

better naming:
get role entities
create roles from names

@alexeh alexeh force-pushed the bugix/update-user-roles branch from 8aede6b to 6c878e2 Compare March 7, 2023 12:53
@alexeh alexeh merged commit 03cdd00 into dev Mar 7, 2023
@alexeh alexeh deleted the bugix/update-user-roles branch March 7, 2023 13:06
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
0