Guest User

Untitled

a guest
May 27th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. class AuthService implements UserDetailsService {
  2. //autowired by grails from our resources.xml bean definition
  3. PasswordEncoder passwordEncoder
  4. UserDetails loadUserByUsername(String email) {
  5. def user = User.findByEmail(email)
  6. if (user)
  7. return new UserWrapper(user)
  8. else
  9. throw new UsernameNotFoundException(email + ' could not be located')
  10. }
  11.  
  12. //convenience method for adding handling password encoding and saving a user
  13. User createUser(User user, String password) {
  14. user.password = passwordEncoder.encodePassword(password, null)
  15. user.save(failOnError: true)
  16. }
  17. }
Add Comment
Please, Sign In to add comment