Search in sources :

Example 1 with DataAccessLevel

use of org.pmiops.workbench.model.DataAccessLevel in project workbench by all-of-us.

the class AuthDomainController method addUserToAuthDomain.

@Override
@AuthorityRequired({ Authority.MANAGE_GROUP })
public ResponseEntity<Void> addUserToAuthDomain(String groupName, AuthDomainRequest request) {
    User user = userDao.findUserByEmail(request.getEmail());
    DataAccessLevel previousAccess = user.getDataAccessLevel();
    try {
        fireCloudService.addUserToGroup(request.getEmail(), groupName);
    } catch (ApiException e) {
        ExceptionUtils.convertFirecloudException(e);
    }
    // TODO(blrubenstein): Parameterize this.
    user.setDataAccessLevel(DataAccessLevel.REGISTERED);
    user.setDisabled(false);
    userDao.save(user);
    userService.logAdminUserAction(user.getUserId(), "user access to  " + groupName + " domain", previousAccess, DataAccessLevel.REGISTERED);
    return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}
Also used : User(org.pmiops.workbench.db.model.User) DataAccessLevel(org.pmiops.workbench.model.DataAccessLevel) ApiException(org.pmiops.workbench.firecloud.ApiException) AuthorityRequired(org.pmiops.workbench.annotations.AuthorityRequired)

Example 2 with DataAccessLevel

use of org.pmiops.workbench.model.DataAccessLevel in project workbench by all-of-us.

the class AuthDomainController method removeUserFromAuthDomain.

@Override
@AuthorityRequired({ Authority.MANAGE_GROUP })
public ResponseEntity<Void> removeUserFromAuthDomain(String groupName, AuthDomainRequest request) {
    User user = userDao.findUserByEmail(request.getEmail());
    DataAccessLevel previousAccess = user.getDataAccessLevel();
    try {
        fireCloudService.removeUserFromGroup(request.getEmail(), groupName);
    } catch (ApiException e) {
        ExceptionUtils.convertFirecloudException(e);
    }
    // TODO(calbach): Teardown any active clusters here.
    user.setDataAccessLevel(DataAccessLevel.REVOKED);
    user.setDisabled(true);
    userDao.save(user);
    userService.logAdminUserAction(user.getUserId(), "user access to  " + groupName + " domain", previousAccess, DataAccessLevel.REVOKED);
    return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}
Also used : User(org.pmiops.workbench.db.model.User) DataAccessLevel(org.pmiops.workbench.model.DataAccessLevel) ApiException(org.pmiops.workbench.firecloud.ApiException) AuthorityRequired(org.pmiops.workbench.annotations.AuthorityRequired)

Aggregations

AuthorityRequired (org.pmiops.workbench.annotations.AuthorityRequired)2 User (org.pmiops.workbench.db.model.User)2 ApiException (org.pmiops.workbench.firecloud.ApiException)2 DataAccessLevel (org.pmiops.workbench.model.DataAccessLevel)2