예제 #1
0
 @Override
 public AccountDTO getAccountByLogin(String login) {
   Account account = accountRepository.findByLogin(login);
   if (account != null) {
     return getMapper().map(accountRepository.findByLogin(login), AccountDTO.class);
   }
   return null;
 }
예제 #2
0
 @Override
 public AccountDTO getAccountByEmail(String email) {
   Account account = accountRepository.findByEmail(email);
   if (account != null) {
     return getMapper().map(accountRepository.findByEmail(email), AccountDTO.class);
   }
   return null;
 }
예제 #3
0
 @Override
 public AccountDTO registerUser(RegistrationForm registrationForm) {
   if (null == registrationForm) {
     log.error("registrationForm was invalid, registration failed");
   } else {
     registrationForm.setPassword(EncodingUtils.encrypt(registrationForm.getPassword()));
     Account account = getMapper().map(registrationForm, Account.class);
     account.setAuthorities(new HashSet<>(Arrays.asList(Authority.AUTHOR)));
     return getMapper().map(accountRepository.save(account), AccountDTO.class);
   }
   return null;
 }
예제 #4
0
 @Override
 public UserDetails loadUserByUsername(String login) throws UsernameNotFoundException {
   UserDetails userDetails = null;
   Account account = accountRepository.findByLogin(login);
   if (null == account) {
     log.warn("User " + login + " not found");
     throw new UsernameNotFoundException("User " + login + " not found.");
   }
   List<GrantedAuthority> authorities = buildUserAuthority(account.getAuthorities());
   userDetails = buildUserForAuthentication(account, authorities);
   return userDetails;
 }