services/src/main/java/org/keycloak/services/resources/admin/UserClientRoleMappingsResource.java
/**
     * Delete client-level roles from user role mapping.
     *
     * @param roles
     */
Delete client-level roles from user role mapping.

@param roles
Delete client - level roles from user role mapping . @param roles
@DELETE
    @Consumes(MediaType.APPLICATION_JSON)
    public void deleteClientRoleMapping(List<RoleRepresentation> roles) {
        auth.requireManage();
        if (roles == null) {
            Set<RoleModel> roleModels = user.getClientRoleMappings(client);
            for (RoleModel roleModel : roleModels) {
                if (!(roleModel.getContainer() instanceof ClientModel)) {
                    ClientModel client = (ClientModel) roleModel.getContainer();
                    if (!client.getId().equals(this.client.getId())) continue;
                }
                user.deleteRoleMapping(roleModel);
            }
        } else {
            for (RoleRepresentation role : roles) {
                RoleModel roleModel = client.getRole(role.getName());
                if (roleModel == null || !roleModel.getId().equals(role.getId())) {
                    throw new NotFoundException("Role not found");
                }
                user.deleteRoleMapping(roleModel);
            }
        }
        adminEvent.operation(OperationType.DELETE).resourcePath(uriInfo).representation(roles).success();
    }
@ DELETE @ Consumes ( MediaType . APPLICATION_JSON ) public void deleteClientRoleMapping ( List < RoleRepresentation > roles ) { auth . requireManage ( ) ; if ( roles == null ) { Set < RoleModel > roleModels = user . getClientRoleMappings ( client ) ; for ( RoleModel roleModel : roleModels ) { if ( ! ( roleModel . getContainer ( ) instanceof ClientModel ) ) { ClientModel client = ( ClientModel ) roleModel . getContainer ( ) ; if ( ! client . getId ( ) . equals ( this . client . getId ( ) ) ) continue ; } user . deleteRoleMapping ( roleModel ) ; } } else { for ( RoleRepresentation role : roles ) { RoleModel roleModel = client . getRole ( role . getName ( ) ) ; if ( roleModel == null || ! roleModel . getId ( ) . equals ( role . getId ( ) ) ) { throw new NotFoundException ( "Role not found" ) ; } user . deleteRoleMapping ( roleModel ) ; } } adminEvent . operation ( OperationType . DELETE ) . resourcePath ( uriInfo ) . representation ( roles ) . success ( ) ; }
Delete client-level roles from user role mapping.
Delete client - level roles from user role mapping .