Skip to content

Commit

Permalink
TRUNK-4049 Daemon cannot assing System Developer role
Browse files Browse the repository at this point in the history
  • Loading branch information
rkorytkowski committed Aug 20, 2013
1 parent 67c9f03 commit e8dca61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion api/src/main/java/org/openmrs/api/impl/UserServiceImpl.java
Expand Up @@ -27,6 +27,7 @@
import org.openmrs.api.db.DAOException;
import org.openmrs.api.db.UserDAO;
import org.openmrs.patient.impl.LuhnIdentifierValidator;
import org.openmrs.util.OpenmrsConstants;
import org.openmrs.util.OpenmrsUtil;
import org.openmrs.util.PrivilegeConstants;
import org.openmrs.util.RoleConstants;
Expand Down Expand Up @@ -425,7 +426,8 @@ private void checkPrivileges(User user) {
List<String> requiredPrivs = new Vector<String>();

for (Role r : roles) {
if (r.getRole().equals(RoleConstants.SUPERUSER) && !authUser.hasRole(RoleConstants.SUPERUSER))
if (r.getRole().equals(RoleConstants.SUPERUSER)

This comment has been minimized.

Copy link
@dkayiwa

dkayiwa Sep 12, 2013

Member

Does this mean that even a super user will not be allowed if they do not have the PrivilegeConstants.ASSIGN_SYSTEM_DEVELOPER_ROLE ?

This comment has been minimized.

Copy link
@rkorytkowski

rkorytkowski Sep 12, 2013

Author Member

Context.hasPrivilege() calls getAuthenticatedUser().hasPrivilege() which always returns true for a superuser regardless if it has that privilege or not.

This comment has been minimized.

Copy link
@dkayiwa

dkayiwa Sep 12, 2013

Member

Oh i see!!! :)

&& !Context.hasPrivilege(PrivilegeConstants.ASSIGN_SYSTEM_DEVELOPER_ROLE))
throw new APIException("You must have the role '" + RoleConstants.SUPERUSER + "' in order to assign it.");
if (r.getPrivileges() != null) {
for (Privilege p : r.getPrivileges())
Expand Down
3 changes: 3 additions & 0 deletions api/src/main/java/org/openmrs/util/PrivilegeConstants.java
Expand Up @@ -530,4 +530,7 @@ public class PrivilegeConstants {

@AddOnStartup(description = "Able to add/edit/retire encounter roles")
public static final String MANAGE_ENCOUNTER_ROLES = "Manage Encounter Roles";

@AddOnStartup(description = "Able to assign System Developer role")
public static final String ASSIGN_SYSTEM_DEVELOPER_ROLE = "Assign System Developer Role";
}

0 comments on commit e8dca61

Please sign in to comment.