Class UsersController
java.lang.Object
org.craftercms.studio.controller.rest.v2.UsersController
@Validated
@RestController
@RequestMapping("/api/2/users")
public class UsersController
extends Object
-
Constructor Summary
ConstructorsConstructorDescriptionUsersController(UserService userService, StudioConfiguration studioConfiguration) -
Method Summary
Modifier and TypeMethodDescriptionchangePassword(@Valid ChangePasswordRequest changePasswordRequest) checkCurrentUserHasGlobalPermissions(@Valid HasPermissionsRequest permissionsRequest) Check if the current authenticated user has global permissionscheckCurrentUserHasSitePermissions(String site, @Valid HasPermissionsRequest permissionsRequest) Check if user has permissions in a site of the current authenticated user APIcreateUser(@Valid CreateUserRequest user) Create user APIdeleteUserProperties(String siteId, @NotEmpty List<@Valid @NotBlank String> properties) deleteUsers(List<@NotNull Long> userIds, List<@NotBlank String> usernames) Delete users APIdisableUsers(@Valid EnableUsers enableUsers) Disable users APIenableUsers(@Valid EnableUsers enableUsers) Enable users APIforgotPassword(@NotBlank String username) getAllUsers(String siteId, String keyword, @jakarta.validation.constraints.PositiveOrZero int offset, @jakarta.validation.constraints.PositiveOrZero int limit, String sort) Get all users APIGet current authenticated user APIGet the global permissions of the current authenticated user APIGet the permissions in a site of the current authenticated user APIgetCurrentUserSiteRoles(@NotBlank String site) Get the roles in a site of the current authenticated user APIgetCurrentUserSites(@jakarta.validation.constraints.PositiveOrZero int offset, @jakarta.validation.constraints.PositiveOrZero int limit) Get the sites of the current authenticated user APIDeprecated.since 3.2, all logout redirects are now handled by Spring SecurityGet user APIgetUserProperties(String siteId) getUserSiteRoles(@NotNull String userId, @NotNull String site) Get user roles for a site APIgetUserSites(@NotNull String userId, @jakarta.validation.constraints.PositiveOrZero int offset, @jakarta.validation.constraints.PositiveOrZero int limit) Get user sites APIresetPassword(@NotBlank String userId, @Valid ResetPasswordRequest resetPasswordRequest) setPassword(@Valid SetPasswordRequest setPasswordRequest) updateUser(@Valid UpdateUserRequest user) Update user APIupdateUserProperties(@Valid UpdateUserPropertiesRequest request) validateToken(jakarta.servlet.http.HttpServletResponse response, @NotBlank String token)
-
Constructor Details
-
UsersController
@ConstructorProperties({"userService","studioConfiguration"}) public UsersController(UserService userService, StudioConfiguration studioConfiguration)
-
-
Method Details
-
getAllUsers
@GetMapping public PaginatedResultList<UserResponse> getAllUsers(@RequestParam(value="site_id",required=false) String siteId, @RequestParam(value="keyword",required=false) String keyword, @PositiveOrZero @RequestParam(value="offset",required=false,defaultValue="0") @jakarta.validation.constraints.PositiveOrZero int offset, @PositiveOrZero @RequestParam(value="limit",required=false,defaultValue="10") @jakarta.validation.constraints.PositiveOrZero int limit, @RequestParam(value="sort",required=false,defaultValue="id asc") String sort) throws ServiceLayerException Get all users API- Parameters:
siteId- Site identifieroffset- Result set offsetlimit- Result set limitsort- Sort order- Returns:
- Response containing list of users
- Throws:
ServiceLayerException
-
createUser
@ResponseStatus(CREATED) @PostMapping(consumes="application/json") public ResultOne<UserResponse> createUser(@Valid @RequestBody @Valid CreateUserRequest user) throws UserAlreadyExistsException, ServiceLayerException, AuthenticationException Create user API- Parameters:
user- User to create- Returns:
- Response object
- Throws:
UserAlreadyExistsExceptionServiceLayerExceptionAuthenticationException
-
updateUser
@PatchMapping(consumes="application/json") public ResultOne<UserResponse> updateUser(@Valid @RequestBody @Valid UpdateUserRequest user) throws ServiceLayerException, UserNotFoundException, AuthenticationException, UserExternallyManagedException Update user API- Parameters:
user- User to update- Returns:
- Response object
- Throws:
ServiceLayerExceptionUserNotFoundExceptionAuthenticationExceptionUserExternallyManagedException
-
deleteUsers
@DeleteMapping public Result deleteUsers(@RequestParam(value="id",required=false) List<@NotNull Long> userIds, @RequestParam(value="username",required=false) List<@NotBlank String> usernames) throws ServiceLayerException, AuthenticationException, UserNotFoundException, UserExternallyManagedException Delete users API- Parameters:
userIds- List of user identifiersusernames- List of usernames- Returns:
- Response object
- Throws:
ServiceLayerExceptionAuthenticationExceptionUserNotFoundExceptionUserExternallyManagedException
-
getUser
@GetMapping(value="/{id}", consumes="*/*", produces="application/json") public ResultOne<UserResponse> getUser(@PathVariable("id") String userId) throws ServiceLayerException, UserNotFoundException, org.craftercms.commons.validation.ValidationException Get user API- Parameters:
userId- User identifier- Returns:
- Response containing user
- Throws:
ServiceLayerExceptionUserNotFoundExceptionorg.craftercms.commons.validation.ValidationException
-
enableUsers
@PatchMapping(value="/enable", consumes="application/json") public ResultList<UserResponse> enableUsers(@Valid @RequestBody @Valid EnableUsers enableUsers) throws ServiceLayerException, UserNotFoundException, AuthenticationException, UserExternallyManagedException Enable users API- Parameters:
enableUsers- Enable users request body (json representation)- Returns:
- Response object
- Throws:
ServiceLayerExceptionUserNotFoundExceptionAuthenticationExceptionUserExternallyManagedException
-
disableUsers
@PatchMapping(value="/disable", consumes="application/json") public ResultList<UserResponse> disableUsers(@Valid @RequestBody @Valid EnableUsers enableUsers) throws ServiceLayerException, UserNotFoundException, AuthenticationException, UserExternallyManagedException Disable users API- Parameters:
enableUsers- Disable users request body (json representation)- Returns:
- Response object
- Throws:
ServiceLayerExceptionUserNotFoundExceptionAuthenticationExceptionUserExternallyManagedException
-
getUserSites
@GetMapping("/{id}/sites") public PaginatedResultList<Site> getUserSites(@NotNull @PathVariable("id") @NotNull String userId, @PositiveOrZero @RequestParam(value="offset",required=false,defaultValue="0") @jakarta.validation.constraints.PositiveOrZero int offset, @PositiveOrZero @RequestParam(value="limit",required=false,defaultValue="10") @jakarta.validation.constraints.PositiveOrZero int limit) throws ServiceLayerException, UserNotFoundException, org.craftercms.commons.validation.ValidationException Get user sites API- Parameters:
userId- User identifier- Returns:
- Response containing list of sites
- Throws:
ServiceLayerExceptionUserNotFoundExceptionorg.craftercms.commons.validation.ValidationException
-
getUserSiteRoles
@GetMapping("/{id}/sites/{site}/roles") public ResultList<String> getUserSiteRoles(@NotNull @PathVariable("id") @NotNull String userId, @NotNull @PathVariable("site") @NotNull String site) throws ServiceLayerException, UserNotFoundException, org.craftercms.commons.validation.ValidationException Get user roles for a site API- Parameters:
userId- User identifiersite- The site ID- Returns:
- Response containing list of roles
- Throws:
ServiceLayerExceptionUserNotFoundExceptionorg.craftercms.commons.validation.ValidationException
-
getCurrentUser
@GetMapping("/me") public ResultOne<AuthenticatedUser> getCurrentUser() throws AuthenticationException, ServiceLayerExceptionGet current authenticated user API- Returns:
- Response containing current authenticated user
- Throws:
AuthenticationExceptionServiceLayerException
-
getCurrentUserSites
@GetMapping("/me/sites") public PaginatedResultList<Site> getCurrentUserSites(@PositiveOrZero @RequestParam(value="offset",required=false,defaultValue="0") @jakarta.validation.constraints.PositiveOrZero int offset, @PositiveOrZero @RequestParam(value="limit",required=false,defaultValue="10") @jakarta.validation.constraints.PositiveOrZero int limit) throws AuthenticationException, ServiceLayerException Get the sites of the current authenticated user API- Returns:
- Response containing current authenticated user sites
- Throws:
AuthenticationExceptionServiceLayerException
-
getCurrentUserSiteRoles
@GetMapping("/me/sites/{site}/roles") public ResultList<String> getCurrentUserSiteRoles(@NotBlank @PathVariable("site") @NotBlank String site) throws AuthenticationException, ServiceLayerException Get the roles in a site of the current authenticated user API- Returns:
- Response containing current authenticated user roles
- Throws:
AuthenticationExceptionServiceLayerException
-
getCurrentUserSsoLogoutUrl
@GetMapping("/me/logout/sso/url") @ResponseStatus(SERVICE_UNAVAILABLE) public Result getCurrentUserSsoLogoutUrl()Deprecated.since 3.2, all logout redirects are now handled by Spring SecurityGet the SSO SP logout URL for the current authenticated user. The system should redirect to this logout URL AFTER local logout. Response entity can be null if user is not authenticated through SSO or if logout is disabled- Returns:
- Response containing SSO logout URL for the current authenticated user
-
forgotPassword
-
changePassword
@PostMapping(value="/me/change_password", consumes="application/json") public ResultOne<UserResponse> changePassword(@Valid @RequestBody @Valid ChangePasswordRequest changePasswordRequest) throws PasswordDoesNotMatchException, ServiceLayerException, UserExternallyManagedException, AuthenticationException, UserNotFoundException -
setPassword
@PostMapping(value="/set_password", consumes="application/json") public ResultOne<UserResponse> setPassword(@Valid @RequestBody @Valid SetPasswordRequest setPasswordRequest) throws UserNotFoundException, UserExternallyManagedException, ServiceLayerException -
resetPassword
@PostMapping(value="/{id}/reset_password", consumes="application/json") public Result resetPassword(@NotBlank @PathVariable("id") @NotBlank String userId, @Valid @RequestBody @Valid ResetPasswordRequest resetPasswordRequest) throws UserNotFoundException, UserExternallyManagedException, ServiceLayerException -
validateToken
@GetMapping(value="/validate_token", produces="application/json") public Result validateToken(jakarta.servlet.http.HttpServletResponse response, @NotBlank @RequestParam("token") @NotBlank String token) throws UserNotFoundException, UserExternallyManagedException, ServiceLayerException -
getUserProperties
@GetMapping(value="/me/properties", produces="application/json") public ResultOne<Map<String,Map<String, getUserPropertiesString>>> (@RequestParam(required=false,defaultValue="") String siteId) throws ServiceLayerException - Throws:
ServiceLayerException
-
updateUserProperties
@PostMapping(value="/me/properties", consumes="application/json", produces="application/json") public ResultOne<Map<String,String>> updateUserProperties(@Valid @RequestBody @Valid UpdateUserPropertiesRequest request) throws ServiceLayerException - Throws:
ServiceLayerException
-
deleteUserProperties
@DeleteMapping(value="/me/properties", produces="application/json") public ResultOne<Map<String,String>> deleteUserProperties(@RequestParam(required=false,defaultValue="") String siteId, @NotEmpty @RequestParam @NotEmpty List<@Valid @NotBlank String> properties) throws ServiceLayerException - Throws:
ServiceLayerException
-
getCurrentUserSitePermissions
@GetMapping(value="/me/sites/{site}/permissions", produces="application/json") public ResultList<String> getCurrentUserSitePermissions(@PathVariable("site") String site) throws ServiceLayerException, UserNotFoundException, ExecutionException Get the permissions in a site of the current authenticated user API- Returns:
- Response containing current authenticated user permissions
- Throws:
ServiceLayerExceptionUserNotFoundExceptionExecutionException
-
checkCurrentUserHasSitePermissions
@PostMapping(value="/me/sites/{site}/has_permissions", consumes="application/json", produces="application/json") public ResultOne<Map<String,Boolean>> checkCurrentUserHasSitePermissions(@PathVariable("site") String site, @Valid @RequestBody @Valid HasPermissionsRequest permissionsRequest) throws ServiceLayerException, UserNotFoundException, ExecutionException Check if user has permissions in a site of the current authenticated user API- Returns:
- Response containing current authenticated user roles
- Throws:
ServiceLayerExceptionUserNotFoundExceptionExecutionException
-
getCurrentUserGlobalPermissions
@GetMapping(value="/me/global/permissions", produces="application/json") public ResultList<String> getCurrentUserGlobalPermissions() throws ServiceLayerException, UserNotFoundException, ExecutionExceptionGet the global permissions of the current authenticated user API- Returns:
- Response containing current authenticated user global permissions
- Throws:
ServiceLayerExceptionUserNotFoundExceptionExecutionException
-
checkCurrentUserHasGlobalPermissions
@PostMapping(value="/me/global/has_permissions", consumes="application/json", produces="application/json") public ResultOne<Map<String,Boolean>> checkCurrentUserHasGlobalPermissions(@Valid @RequestBody @Valid HasPermissionsRequest permissionsRequest) throws ServiceLayerException, UserNotFoundException, ExecutionException Check if the current authenticated user has global permissions- Returns:
- Response containing current authenticated user roles
- Throws:
ServiceLayerExceptionUserNotFoundExceptionExecutionException
-