Class UserController
java.lang.Object
com.mt.ecommerce.product.controller.UserController
Controller for managing user-related operations.
Provides endpoints for validating user roles and fetching user-specific data.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<?>
authenticateAndGetToken
(org.springframework.security.core.userdetails.UserDetails userDetails) Endpoint to fetch the store information associated with the authenticated vendor user.void
Endpoint to validate if the authenticated user has ROLE_ADMIN.void
Endpoint to validate if the authenticated user has ROLE_USER.void
Endpoint to validate if the authenticated user has either ROLE_VENDOR or ROLE_ADMIN.
-
Constructor Details
-
UserController
-
-
Method Details
-
validVendorOrAdminUser
@PreAuthorize("hasAnyAuthority(\'ROLE_VENDOR\', \'ROLE_ADMIN\')") @GetMapping("/vendor") public void validVendorOrAdminUser()Endpoint to validate if the authenticated user has either ROLE_VENDOR or ROLE_ADMIN. Accessible by users with ROLE_VENDOR or ROLE_ADMIN. -
validAdminUser
@PreAuthorize("hasAuthority(\'ROLE_ADMIN\')") @GetMapping("/admin") public void validAdminUser()Endpoint to validate if the authenticated user has ROLE_ADMIN. Accessible only by users with ROLE_ADMIN. -
validateUserRole
@GetMapping("") public void validateUserRole()Endpoint to validate if the authenticated user has ROLE_USER. Accessible only by users with ROLE_USER. -
authenticateAndGetToken
@PreAuthorize("hasAnyAuthority(\'ROLE_VENDOR\', \'ROLE_ADMIN\')") @GetMapping(value="/getStore", produces="application/json") public org.springframework.http.ResponseEntity<?> authenticateAndGetToken(@AuthenticationPrincipal org.springframework.security.core.userdetails.UserDetails userDetails) Endpoint to fetch the store information associated with the authenticated vendor user. Accessible by users with ROLE_VENDOR or ROLE_ADMIN.- Parameters:
userDetails
- the authenticated user's details- Returns:
- ResponseEntity containing the store information or an error message
-