Skip to content

feat: update user management functionality to allow/return role and a… - #20

Merged
Mats057 merged 8 commits into
mainfrom
bugfix/missing-role-and-ban-management
Mar 7, 2026
Merged

feat: update user management functionality to allow/return role and a…#20
Mats057 merged 8 commits into
mainfrom
bugfix/missing-role-and-ban-management

Conversation

@Mats057

@Mats057 Mats057 commented Mar 1, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces enhancements to user management, particularly around admin-level operations and user updates. The main changes include the creation of a new AdminUserDTO for exposing additional user fields to admins, updates to allow modifying user roles and account status with proper access control, and improvements to user uniqueness checks. Below are the key changes grouped by theme:

Admin User Data Exposure and Mapping:

  • Introduced a new AdminUserDTO record to represent user data with admin-specific fields such as role, accountNonLocked, and timestamps.
  • Updated the UserController's getAll endpoint to return a page of AdminUserDTO instead of the standard UserDTO, and mapped users to this new DTO using a new toAdminDTO method in UserMapper. [1] [2]

User Update Enhancements and Access Control:

  • Extended UpdateUserDTO to include role and accountNonLocked fields, allowing these properties to be updated.
  • Modified the UserService.update method to:
    • Only allow updates to role and accountNonLocked if the current user has admin privileges, throwing an AccessDeniedException otherwise.
    • Use new repository methods to ensure username and email uniqueness, excluding the current user from the check. [1] [2]

Repository Improvements:

  • Added existsByUsernameAndIdNot and existsByEmailAndIdNot methods to UserRepository to support uniqueness checks during user updates.

Supporting Imports and Constants:

  • Added necessary imports for new DTOs, security checks, and constants in relevant files. [1] [2]

These changes collectively strengthen admin capabilities, enforce stricter access control, and improve the reliability of user data updates.

@github-actions

github-actions Bot commented Mar 1, 2026

Copy link
Copy Markdown

✅ Test Results - Booker API

📊 Summary

  • Total Tests: 60
  • Failures: 0
  • Errors: 0
  • Status: ALL TESTS PASSED

🎉 Ready to merge!

📁 View Test Reports

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances admin-oriented user management by exposing additional user fields to admins, allowing admins to update role/lock status, and improving username/email uniqueness checks during user updates.

Changes:

  • Added AdminUserDTO plus mapping support to expose role, accountNonLocked, and timestamps to admins.
  • Updated /users (admin-only) list endpoint to return Page<AdminUserDTO> instead of Page<UserDTO>.
  • Improved update-time uniqueness checks by excluding the current user from username/email “already exists” queries, and added admin gating for role/lock updates.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/main/java/com/booker/services/UserService.java Adds admin-only update behavior for role/accountNonLocked and adjusts uniqueness checks during updates.
src/main/java/com/booker/repositories/UserRepository.java Adds existsByUsernameAndIdNot / existsByEmailAndIdNot helpers for update-time uniqueness.
src/main/java/com/booker/mappers/UserMapper.java Adds toAdminDTO mapper for admin-facing user fields.
src/main/java/com/booker/controllers/UserController.java Changes admin-only GET /users to return admin DTOs.
src/main/java/com/booker/DTO/User/UpdateUserDTO.java Extends update payload with role and accountNonLocked.
src/main/java/com/booker/DTO/User/AdminUserDTO.java Introduces new admin-facing user DTO.

Comment thread src/main/java/com/booker/services/UserService.java Outdated
Comment thread src/main/java/com/booker/DTO/User/UpdateUserDTO.java Outdated

Copilot AI commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

@Mats057 I've opened a new pull request, #21, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits March 1, 2026 22:27
Co-authored-by: Mats057 <119885089+Mats057@users.noreply.github.com>
@github-actions

github-actions Bot commented Mar 1, 2026

Copy link
Copy Markdown

✅ Test Results - Booker API

📊 Summary

  • Total Tests: 60
  • Failures: 0
  • Errors: 0
  • Status: ALL TESTS PASSED

🎉 Ready to merge!

📁 View Test Reports

@github-actions

github-actions Bot commented Mar 1, 2026

Copy link
Copy Markdown

✅ Test Results - Booker API

📊 Summary

  • Total Tests: 60
  • Failures: 0
  • Errors: 0
  • Status: ALL TESTS PASSED

🎉 Ready to merge!

📁 View Test Reports

@github-actions

github-actions Bot commented Mar 1, 2026

Copy link
Copy Markdown

✅ Test Results - Booker API

📊 Summary

  • Total Tests: 60
  • Failures: 0
  • Errors: 0
  • Status: ALL TESTS PASSED

🎉 Ready to merge!

📁 View Test Reports

Comment thread src/main/java/com/booker/DTO/User/UpdateUserDTO.java Outdated
@github-actions

github-actions Bot commented Mar 7, 2026

Copy link
Copy Markdown

✅ Test Results - Booker API

📊 Summary

  • Total Tests: 60
  • Failures: 0
  • Errors: 0
  • Status: ALL TESTS PASSED

🎉 Ready to merge!

📁 View Test Reports

@Mats057
Mats057 merged commit eac8ffa into main Mar 7, 2026
2 checks passed
@Mats057
Mats057 deleted the bugfix/missing-role-and-ban-management branch March 7, 2026 18:47
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.

4 participants