Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AuthService implements UserDetailsService {
- //autowired by grails from our resources.xml bean definition
- PasswordEncoder passwordEncoder
- UserDetails loadUserByUsername(String email) {
- def user = User.findByEmail(email)
- if (user)
- return new UserWrapper(user)
- else
- throw new UsernameNotFoundException(email + ' could not be located')
- }
- //convenience method for adding handling password encoding and saving a user
- User createUser(User user, String password) {
- user.password = passwordEncoder.encodePassword(password, null)
- user.save(failOnError: true)
- }
- }
Add Comment
Please, Sign In to add comment