Skip to content

Commit

Permalink
add "deactivated" to user dashboard, list-users API #2419 #4475
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Mar 12, 2021
1 parent 3713104 commit c2b7b0a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/edu/harvard/iq/dataverse/UserServiceBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ private AuthenticatedUser createAuthenticatedUserForView (Object[] dbRowValues,

user.setAuthProviderId(UserUtil.getStringOrNull(dbRowValues[11]));
user.setAuthProviderFactoryAlias(UserUtil.getStringOrNull(dbRowValues[12]));


user.setDeactivated((Boolean)(dbRowValues[13]));
user.setDeactivatedTime(UserUtil.getTimestampOrNull(dbRowValues[14]));

user.setRoles(roles);
return user;
}
Expand Down Expand Up @@ -417,7 +420,8 @@ private List<Object[]> getUserListCore(String searchTerm,
qstr += " u.affiliation, u.superuser,";
qstr += " u.position,";
qstr += " u.createdtime, u.lastlogintime, u.lastapiusetime, ";
qstr += " prov.id, prov.factoryalias";
qstr += " prov.id, prov.factoryalias, ";
qstr += " u.deactivated, u.deactivatedtime ";
qstr += " FROM authenticateduser u,";
qstr += " authenticateduserlookup prov_lookup,";
qstr += " authenticationproviderrow prov";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ public JsonObjectBuilder toJson() {
authenicatedUserJson.add("lastLoginTime", UserUtil.getTimestampStringOrNull(this.lastLoginTime));
authenicatedUserJson.add("lastApiUseTime", UserUtil.getTimestampStringOrNull(this.lastApiUseTime));

authenicatedUserJson.add("deactivated", this.deactivated);
authenicatedUserJson.add("deactivatedTime", UserUtil.getTimestampStringOrNull(this.deactivatedTime));

return authenicatedUserJson;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/propertyFiles/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ dashboard.list_users.tbl_header.authProviderFactoryAlias=Authentication
dashboard.list_users.tbl_header.createdTime=Created Time
dashboard.list_users.tbl_header.lastLoginTime=Last Login Time
dashboard.list_users.tbl_header.lastApiUseTime=Last API Use Time
dashboard.list_users.tbl_header.deactivated=deactivated
dashboard.list_users.tbl_header.roles.removeAll=Remove All
dashboard.list_users.tbl_header.roles.removeAll.header=Remove All Roles
dashboard.list_users.tbl_header.roles.removeAll.confirmationText=Are you sure you want to remove all roles for user {0}?
Expand Down
1 change: 1 addition & 0 deletions src/main/webapp/dashboard-users.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
</p:column>
<p:column width="12%" headerText="#{bundle['dashboard.list_users.tbl_header.authProviderFactoryAlias']}">
<h:outputText value="#{DashboardUsersPage.getAuthProviderFriendlyName(user.authProviderId)}" />
<h:outputText rendered="#{user.deactivated}" value=" (#{bundle['dashboard.list_users.tbl_header.deactivated']})" />
</p:column>
<p:column headerText="#{bundle['dashboard.list_users.tbl_header.roles']}">
<h:outputText value="#{user.roles}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import static javax.ws.rs.core.Response.Status.OK;
import static javax.ws.rs.core.Response.Status.UNAUTHORIZED;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.startsWith;
import org.junit.BeforeClass;
import org.junit.Test;

Expand Down Expand Up @@ -93,6 +94,14 @@ public void testDeactivateUser() {
.statusCode(OK.getStatusCode())
.body("data.deactivated", equalTo(true));

Response findUser = UtilIT.filterAuthenticatedUsers(superuserApiToken, username, null, 100, null);
findUser.prettyPrint();
findUser.then().assertThat()
.statusCode(OK.getStatusCode())
.body("data.users[0].userIdentifier", equalTo(username))
.body("data.users[0].deactivated", equalTo(true))
.body("data.users[0].deactivatedTime", startsWith("2"));

Response getUserDeactivated = UtilIT.getAuthenticatedUserByToken(apiToken);
getUserDeactivated.prettyPrint();
getUserDeactivated.then().assertThat().statusCode(BAD_REQUEST.getStatusCode());
Expand Down

0 comments on commit c2b7b0a

Please sign in to comment.