@Override
  @Transactional
  public Users save(Users user) {
    String pwd = user.getPassword();
    user.setPassword(EncryptUtil.encrypt(pwd));

    Users getUser = usersDao.save(user);
    if (getUser.getEmail().equals(user.getEmail())) {
      UsersAuth auth = new UsersAuth();
      auth.setEmail(user.getEmail());
      auth.setAuthority("ROLE_USER");
      this.usersDao.saveAuth(auth);
      return getUser;
    } else {
      return null;
    }
  }
 @Override
 @Transactional(propagation = Propagation.REQUIRES_NEW)
 public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
   Users user = usersDao.loadUserByUsername(username);
   Set<UsersAuth> set = user.getUsersAuths();
   HashSet<GrantedAuthority> hashSet = new HashSet<GrantedAuthority>();
   for (UsersAuth auth : set) {
     final String authority = auth.getAuthority();
     hashSet.add(
         new GrantedAuthority() {
           @Override
           public String getAuthority() {
             return authority;
           }
         });
   }
   user.setAuthorities(hashSet);
   return user;
 }