diff --git a/api/src/main/java/org/openmrs/api/impl/UserServiceImpl.java b/api/src/main/java/org/openmrs/api/impl/UserServiceImpl.java index 202135a91c93..c63b1a3dde73 100644 --- a/api/src/main/java/org/openmrs/api/impl/UserServiceImpl.java +++ b/api/src/main/java/org/openmrs/api/impl/UserServiceImpl.java @@ -652,7 +652,7 @@ public void changePassword(User user, String oldPassword, String newPassword) th throw new APIException("new.password.equal.to.old", (Object[]) null); } - if ("admin".equals(user.getUsername()) && Boolean.parseBoolean( + if ("admin".equals(user.getSystemId()) && Boolean.parseBoolean( Context.getRuntimeProperties().getProperty(ADMIN_PASSWORD_LOCKED_PROPERTY, "false"))) { throw new APIException("admin.password.is.locked"); } diff --git a/api/src/test/java/org/openmrs/api/UserServiceTest.java b/api/src/test/java/org/openmrs/api/UserServiceTest.java index 1b3b1bc61263..f876fc3b80ed 100644 --- a/api/src/test/java/org/openmrs/api/UserServiceTest.java +++ b/api/src/test/java/org/openmrs/api/UserServiceTest.java @@ -399,7 +399,7 @@ public void changePassword_shouldRespectLockingViaRuntimeProperty() { assertThat("admin", is(Context.getAuthenticatedUser().getUsername())); User u = userService.getUserByUsername(ADMIN_USERNAME); - assertThat(u.isSuperUser(), is(true)); + assertThat(u.getSystemId(), is("admin")); Properties props = Context.getRuntimeProperties(); props.setProperty(UserService.ADMIN_PASSWORD_LOCKED_PROPERTY, "true");