@PostConstruct protected void initialize() { accountRepository.deleteAll(); save(new Account("user", "demo", "ROLE_USER")); save(new Account("admin", "admin", "ROLE_ADMIN")); save(new Account("*****@*****.**", "qaz123", "ROLE_USER")); }
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { Account account = accountRepository.findOneByEmail(username); if (account == null) { throw new UsernameNotFoundException("user not found"); } return createUser(account); }
@Transactional public Account save(Account account) { account.setPassword(passwordEncoder.encode(account.getPassword())); accountRepository.save(account); return account; }