@Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false) public void update(long userId, EditUser editUserForm) { User loggedIn = MyTools.getSessionUser(); MyTools.validate(loggedIn.getId() == userId, "noPermission"); User user = userRepo.findOne(userId); user.setName(editUserForm.getName()); userRepo.save(user); }
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User user = userRepo.findByEmail(username); if (user == null) { throw new UsernameNotFoundException(username); } return new UserDetailsImpl(user); }
@Override public User findOne(long userId) { User loggedIn = MyTools.getSessionUser(); User user = userRepo.findOne(userId); // if nobody is logged in or if the user is not seeing is own profile if (loggedIn == null || loggedIn.getId() != user.getId()) user.setEmail("********"); return user; }
@Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false) public void signupForm(SignupForm signupForm) { User user = new User(); user.setEmail(signupForm.getEmail()); user.setName(signupForm.getFirstname()); user.setPassword(passwordEncoder.encode(signupForm.getPassword())); // user.getRoles().add(Role.); // user.setVerificationCode(RandomStringUtils.randomAlphanumeric(16)); userRepo.save(user); /** * ******************************************************************** figure out how to create * email verification link -put it here String ... */ // ////////////////////////////////////////////////////////////////// }
public List<User> findAll() { return userRepo.findAll(); }