use of py.org.fundacionparaguaya.pspserver.security.entities.UserRoleEntity in project FP-PSP-SERVER by FundacionParaguaya.
the class UserDetailsServiceImpl method loadUserByUsername.
@Override
public UserDetailsDTO loadUserByUsername(String username) throws UsernameNotFoundException {
LOG.info("Loading user details: {}", username);
UserEntity user = userRepository.findOneByUsername(username).orElseThrow(() -> new UsernameNotFoundException("Username not found " + username));
List<UserRoleEntity> roles = userRoleRepo.findByUser(user);
UserApplicationEntity userApp = userApplicationRepo.findByUser(user).orElseGet(UserApplicationEntity::new);
Optional<OrganizationEntity> organization = userApp.getOrganizationOpt();
Optional<ApplicationEntity> application = userApp.getApplicationOpt();
return UserDetailsDTO.builder().username(user.getUsername()).password(user.getPass()).enabled(user.isActive()).application(application.map(applicationMapper::entityToDto).orElse(null)).organization(organization.map(organizationMapper::entityToDto).orElse(null)).grantedAuthorities(this.getGrantedAuthorities(roles)).build();
}
use of py.org.fundacionparaguaya.pspserver.security.entities.UserRoleEntity in project FP-PSP-SERVER by FundacionParaguaya.
the class UserRoleServiceImpl method addUserRole.
@Override
public UserRoleDTO addUserRole(UserRoleDTO userRoleDTO) {
UserRoleEntity userRole = new UserRoleEntity();
BeanUtils.copyProperties(userRoleDTO, userRole);
UserRoleEntity newUserRole = userRoleRepository.save(userRole);
return userRoleMapper.entityToDto(newUserRole);
}
use of py.org.fundacionparaguaya.pspserver.security.entities.UserRoleEntity in project FP-PSP-SERVER by FundacionParaguaya.
the class UserServiceImpl method createUserRole.
private UserRoleEntity createUserRole(UserEntity user, Role role) {
UserRoleEntity userRole = new UserRoleEntity();
userRole.setUser(user);
userRole.setRole(role);
return userRoleRepository.save(userRole);
}
Aggregations