use of org.hisp.dhis.user.UserCredentialsDto in project dhis2-core by dhis2.
the class MeController method getCurrentUser.
@GetMapping
public ResponseEntity<JsonNode> getCurrentUser(@CurrentUser(required = true) User user, @RequestParam(defaultValue = "*") List<String> fields) {
if (fieldsContains("access", fields)) {
Access access = aclService.getAccess(user, user);
user.setAccess(access);
}
Map<String, Serializable> userSettings = userSettingService.getUserSettingsWithFallbackByUserAsMap(user, USER_SETTING_KEYS, true);
List<String> programs = programService.getUserPrograms().stream().map(BaseIdentifiableObject::getUid).collect(Collectors.toList());
List<String> dataSets = dataSetService.getUserDataRead(user).stream().map(BaseIdentifiableObject::getUid).collect(Collectors.toList());
MeDto meDto = new MeDto(user, userSettings, programs, dataSets);
UserCredentialsDto userCredentialsDto = user.getUserCredentials();
meDto.setUserCredentials(userCredentialsDto);
var params = org.hisp.dhis.fieldfiltering.FieldFilterParams.of(meDto, fields);
ObjectNode jsonNodes = fieldFilterService.toObjectNodes(params).get(0);
return ResponseEntity.ok(jsonNodes);
}
use of org.hisp.dhis.user.UserCredentialsDto in project dhis2-core by dhis2.
the class UserController method populateUserCredentialsDtoFields.
private void populateUserCredentialsDtoFields(User user) {
UserCredentialsDto userCredentialsRaw = user.getUserCredentialsRaw();
if (userCredentialsRaw != null) {
copyProperties(userCredentialsRaw, user, KEY_PASSWORD);
if (userCredentialsRaw.getPassword() != null) {
user.setPassword(userCredentialsRaw.getPassword());
}
Set<UserAuthorityGroup> userRoles = userCredentialsRaw.getUserRoles();
if (userRoles != null) {
user.setUserAuthorityGroups(userRoles);
}
}
}
Aggregations