return okWithLocation(routes.OrganizationApp.members(organizationName).url());
}
}
private static Result validateForDeleteMember(String organizationName, Long userId) {
Organization organization = Organization.findByName(organizationName);
if (organization == null) {
return notFound(ErrorViews.NotFound.render("organization.member.unknownOrganization", organization));
}
if (!OrganizationUser.exist(organization.id, userId)) {
flash(Constants.WARNING, "organization.member.isNotAMember");
return okWithLocation(routes.OrganizationApp.members(organizationName).url());
}
User currentUser = UserApp.currentUser();
if (!AccessControl.isAllowed(currentUser, organization.asResource(), Operation.UPDATE)
&& !currentUser.id.equals(userId)) {
flash(Constants.WARNING, "organization.member.needManagerRole");
return okWithLocation(routes.OrganizationApp.members(organizationName).url());
}
if (OrganizationUser.isAdmin(organization.id, userId) && organization.getAdmins().size() == 1) {
flash(Constants.WARNING, "organization.member.atLeastOneAdmin");
return okWithLocation(routes.OrganizationApp.members(organizationName).url());
}
return null;