Add super admin role in super admin assign role method.
This commit is contained in:
parent
4ae79d13a3
commit
434034b4f5
|
@ -54,10 +54,11 @@ public class SuperAdminController {
|
|||
*
|
||||
*/
|
||||
@RequestMapping(value = "/assign", method = RequestMethod.POST)
|
||||
public ResponseEntity<Response> assignRole(@RequestParam(required = false) String email) {
|
||||
public ResponseEntity<Response> assignRole(@RequestParam(required = false) String email,
|
||||
@RequestParam(required = false, defaultValue = "false") boolean superAdmin) {
|
||||
List<Integer> coPersonIds = registryService.getCoPersonIdsByEmail(email);
|
||||
if (coPersonIds.size() > 0) {
|
||||
Integer couId = registryService.getCouId(AuthoritiesUtils.portalAdminRole());
|
||||
Integer couId = registryService.getCouId(superAdmin?AuthoritiesUtils.superAdminRole():AuthoritiesUtils.portalAdminRole());
|
||||
if (couId != null) {
|
||||
coPersonIds.forEach(coPersonId -> {
|
||||
String identifier = registryService.getIdentifierByCoPersonId(coPersonId);
|
||||
|
@ -75,10 +76,11 @@ public class SuperAdminController {
|
|||
* Remove portal admin role from logged in user or user with @email
|
||||
*/
|
||||
@RequestMapping(value = "/remove", method = RequestMethod.DELETE)
|
||||
public ResponseEntity<Response> removeRole( @RequestParam(required = false) String email) {
|
||||
public ResponseEntity<Response> removeRole( @RequestParam(required = false) String email,
|
||||
@RequestParam(required = false, defaultValue = "false") boolean superAdmin) {
|
||||
List<Integer> coPersonIds = registryService.getCoPersonIdsByEmail(email);
|
||||
if (coPersonIds.size() > 0) {
|
||||
Integer couId = registryService.getCouId(AuthoritiesUtils.portalAdminRole());
|
||||
Integer couId = registryService.getCouId(superAdmin?AuthoritiesUtils.superAdminRole():AuthoritiesUtils.portalAdminRole());
|
||||
if (couId != null) {
|
||||
coPersonIds.forEach(coPersonId -> {
|
||||
String identifier = registryService.getIdentifierByCoPersonId(coPersonId);
|
||||
|
|
|
@ -7,6 +7,11 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
|||
public class AuthoritiesUtils {
|
||||
|
||||
public static String PORTAL_ADMIN = "PORTAL_ADMINISTRATOR";
|
||||
public static String SUPER_ADMIN = "SUPER_ADMINISTRATOR";
|
||||
|
||||
public static String superAdminRole() {
|
||||
return "Super Administrator";
|
||||
}
|
||||
|
||||
public static String portalAdminRole() {
|
||||
return "Portal Administrator";
|
||||
|
|
Loading…
Reference in New Issue