From 942ec6ac067693457aa941bb09fce79646f6e9e4 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Wed, 20 May 2015 16:43:52 +0900 Subject: [PATCH] Group: Fix an error when update member's role "A group have to have at least one admin" error occured when update a group member's role to "member" if the user who updates was the last group admin. The error should occur if the updated user, not the user who updates, was the last admin. --- app/controllers/OrganizationApp.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/OrganizationApp.java b/app/controllers/OrganizationApp.java index 832706be4..eb9e69940 100644 --- a/app/controllers/OrganizationApp.java +++ b/app/controllers/OrganizationApp.java @@ -240,7 +240,8 @@ private static Result validateForEditMember(Form roleForm, String organiza return okWithLocation(routes.OrganizationApp.members(organizationName).url()); } - if (organization.isLastAdmin(currentUser) && roleForm.get().id.equals(RoleType.ORG_MEMBER.roleType())) { + if (organization.isLastAdmin(User.find.byId(userId)) + && roleForm.get().id.equals(RoleType.ORG_MEMBER.roleType())) { flash(Constants.WARNING, "organization.member.atLeastOneAdmin"); return okWithLocation(routes.OrganizationApp.members(organizationName).url()); }