Class UserController

java.lang.Object
com.mt.ecommerce.product.controller.UserController

@RestController @RequestMapping("/user") public class UserController extends Object
Controller for managing user-related operations. Provides endpoints for validating user roles and fetching user-specific data.
  • Constructor Details

  • 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