Can’t create user with role different from ADMIN

Home / Uncategorized / Can’t create user with role different from ADMIN

Question:
I can’t create user with roles different from ADMIN, the server responded with a status of 403 (Forbidden).

I have try :@PostMapping("/users")
@Timed
@Secured({AuthoritiesConstants.ADMIN,AuthoritiesConstants.MANAGER})
public ResponseEntity createUser(@Valid @RequestBody ManagedUserVM managedUserVM) throws URISyntaxException {
log.debug("REST request to save User : {}", managedUserVM);

}

and
@RestController
@RequestMapping("/api")
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class UserResource {
@PostMapping("/users")
@Timed
@PreAuthorize("hasAnyRole(‘ROLE_ADMIN’,’ROLE_MANAGER’)")
public ResponseEntity createUser(@Valid @RequestBody ManagedUserVM managedUserVM) throws URISyntaxException {
log.debug("REST request to save User : {}", managedUserVM);
//….

}
//….
}


Answer:

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *