refactor MyBookings handling front and back #326
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request implements stricter role-based access control and organization context validation for the "My Bookings" feature. It refactors both backend and frontend logic to ensure only users with appropriate roles ("user" or "requester") and a valid organization context can view their bookings. The changes also improve error handling and user feedback for invalid context or insufficient permissions.
Backend validation and API changes:
BookingController
andBookingService
to validate the presence ofx-org-id
,x-role-name
, and user ID in requests, throwing exceptions if missing, and refactored method signatures to require these parameters explicitly. [1] [2] [3]Frontend logic and state management:
getOwnBookings
and related API method to fetch bookings for the current authenticated user with required organization and role context. Also introduced aclearUserBookings
action to reset state when context changes. [1] [2] [3] [4] [5]MyBookings.tsx
to use role and organization context for fetching bookings, display error messages for invalid context or insufficient role, and clear bookings when context changes. [1] [2] [3] [4] [5] [6] [7]User feedback and translations:
Miscellaneous:
package.json
for consistency. [1] [2]