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
Constructors Constructor Description UsersController(UserService userService, StudioConfiguration studioConfiguration)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ResultOne<User>
changePassword(@Valid ChangePasswordRequest changePasswordRequest)
ResultOne<Map<String,Boolean>>
checkCurrentUserHasGlobalPermissions(@Valid HasPermissionsRequest permissionsRequest)
Check if the current authenticated user has global permissionsResultOne<Map<String,Boolean>>
checkCurrentUserHasSitePermissions(String site, @Valid HasPermissionsRequest permissionsRequest)
Check if user has permissions in a site of the current authenticated user APIResultOne<User>
createUser(@Valid CreateUserRequest user)
Create user APIResultOne<Map<String,String>>
deleteUserProperties(String siteId, @Valid @NotEmpty List<@NotBlank String> properties)
Result
deleteUsers(List<@NotNull Long> userIds, List<@NotBlank String> usernames)
Delete users APIResultList<User>
disableUsers(@Valid EnableUsers enableUsers)
Disable users APIResultList<User>
enableUsers(@Valid EnableUsers enableUsers)
Enable users APIResultOne<String>
forgotPassword(@NotBlank String username)
PaginatedResultList<User>
getAllUsers(String siteId, String keyword, @javax.validation.constraints.PositiveOrZero int offset, @javax.validation.constraints.PositiveOrZero int limit, String sort)
Get all users APIResultOne<AuthenticatedUser>
getCurrentUser()
Get current authenticated user APIResultList<String>
getCurrentUserGlobalPermissions()
Get the global permissions of the current authenticated user APIResultList<String>
getCurrentUserSitePermissions(String site)
Get the permissions in a site of the current authenticated user APIResultList<String>
getCurrentUserSiteRoles(@NotBlank String site)
Get the roles in a site of the current authenticated user APIPaginatedResultList<Site>
getCurrentUserSites(@javax.validation.constraints.PositiveOrZero int offset, @javax.validation.constraints.PositiveOrZero int limit)
Get the sites of the current authenticated user APIResult
getCurrentUserSsoLogoutUrl()
Deprecated.since 3.2, all logout redirects are now handled by Spring SecurityResultOne<User>
getUser(String userId)
Get user APIResultOne<Map<String,Map<String,String>>>
getUserProperties(String siteId)
ResultList<String>
getUserSiteRoles(@NotNull String userId, @NotNull String site)
Get user roles for a site APIPaginatedResultList<Site>
getUserSites(@NotNull String userId, @javax.validation.constraints.PositiveOrZero int offset, @javax.validation.constraints.PositiveOrZero int limit)
Get user sites APIResult
resetPassword(@NotBlank String userId, @Valid ResetPasswordRequest resetPasswordRequest)
ResultOne<User>
setPassword(@Valid SetPasswordRequest setPasswordRequest)
ResultOne<User>
updateUser(@Valid UpdateUserRequest user)
Update user APIResultOne<Map<String,String>>
updateUserProperties(@Valid UpdateUserPropertiesRequest request)
Result
validateToken(javax.servlet.http.HttpServletResponse response, @NotBlank String token)
-
-
-
Constructor Detail
-
UsersController
@ConstructorProperties({"userService","studioConfiguration"}) public UsersController(UserService userService, StudioConfiguration studioConfiguration)
-
-
Method Detail
-
getAllUsers
@GetMapping public PaginatedResultList<User> getAllUsers(@RequestParam(value="site_id",required=false) String siteId, @RequestParam(value="keyword",required=false) String keyword, @PositiveOrZero @RequestParam(value="offset",required=false,defaultValue="0") @javax.validation.constraints.PositiveOrZero int offset, @PositiveOrZero @RequestParam(value="limit",required=false,defaultValue="10") @javax.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<User> createUser(@Valid @RequestBody @Valid CreateUserRequest user) throws UserAlreadyExistsException, ServiceLayerException, AuthenticationException
Create user API- Parameters:
user
- User to create- Returns:
- Response object
- Throws:
UserAlreadyExistsException
ServiceLayerException
AuthenticationException
-
updateUser
@PatchMapping(consumes="application/json") public ResultOne<User> updateUser(@Valid @RequestBody @Valid UpdateUserRequest user) throws ServiceLayerException, UserNotFoundException, AuthenticationException, UserExternallyManagedException
Update user API- Parameters:
user
- User to update- Returns:
- Response object
- Throws:
ServiceLayerException
UserNotFoundException
AuthenticationException
UserExternallyManagedException
-
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:
ServiceLayerException
AuthenticationException
UserNotFoundException
UserExternallyManagedException
-
getUser
@GetMapping(value="/{id}", consumes="*/*", produces="application/json") public ResultOne<User> 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:
ServiceLayerException
UserNotFoundException
org.craftercms.commons.validation.ValidationException
-
enableUsers
@PatchMapping(value="/enable", consumes="application/json") public ResultList<User> 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:
ServiceLayerException
UserNotFoundException
AuthenticationException
UserExternallyManagedException
-
disableUsers
@PatchMapping(value="/disable", consumes="application/json") public ResultList<User> 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:
ServiceLayerException
UserNotFoundException
AuthenticationException
UserExternallyManagedException
-
getUserSites
@GetMapping("/{id}/sites") public PaginatedResultList<Site> getUserSites(@NotNull @PathVariable("id") @NotNull String userId, @PositiveOrZero @RequestParam(value="offset",required=false,defaultValue="0") @javax.validation.constraints.PositiveOrZero int offset, @PositiveOrZero @RequestParam(value="limit",required=false,defaultValue="10") @javax.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:
ServiceLayerException
UserNotFoundException
org.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:
ServiceLayerException
UserNotFoundException
org.craftercms.commons.validation.ValidationException
-
getCurrentUser
@GetMapping("/me") public ResultOne<AuthenticatedUser> getCurrentUser() throws AuthenticationException, ServiceLayerException
Get current authenticated user API- Returns:
- Response containing current authenticated user
- Throws:
AuthenticationException
ServiceLayerException
-
getCurrentUserSites
@GetMapping("/me/sites") public PaginatedResultList<Site> getCurrentUserSites(@PositiveOrZero @RequestParam(value="offset",required=false,defaultValue="0") @javax.validation.constraints.PositiveOrZero int offset, @PositiveOrZero @RequestParam(value="limit",required=false,defaultValue="10") @javax.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:
AuthenticationException
ServiceLayerException
-
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:
AuthenticationException
ServiceLayerException
-
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
@GetMapping("/forgot_password") public ResultOne<String> forgotPassword(@NotBlank @RequestParam("username") @NotBlank String username) throws ServiceLayerException
- Throws:
ServiceLayerException
-
changePassword
@PostMapping("/me/change_password") public ResultOne<User> changePassword(@Valid @RequestBody @Valid ChangePasswordRequest changePasswordRequest) throws PasswordDoesNotMatchException, ServiceLayerException, UserExternallyManagedException, AuthenticationException, UserNotFoundException
-
setPassword
@PostMapping("/set_password") public ResultOne<User> setPassword(@Valid @RequestBody @Valid SetPasswordRequest setPasswordRequest) throws UserNotFoundException, UserExternallyManagedException, ServiceLayerException
-
resetPassword
@PostMapping("/{id}/reset_password") 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(javax.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,String>>> getUserProperties(@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, @Valid @NotEmpty @RequestParam @Valid @NotEmpty List<@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:
ServiceLayerException
UserNotFoundException
ExecutionException
-
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:
ServiceLayerException
UserNotFoundException
ExecutionException
-
getCurrentUserGlobalPermissions
@GetMapping(value="/me/global/permissions", produces="application/json") public ResultList<String> getCurrentUserGlobalPermissions() throws ServiceLayerException, UserNotFoundException, ExecutionException
Get the global permissions of the current authenticated user API- Returns:
- Response containing current authenticated user global permissions
- Throws:
ServiceLayerException
UserNotFoundException
ExecutionException
-
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:
ServiceLayerException
UserNotFoundException
ExecutionException
-
-