Guest User

Untitled

a guest
Nov 3rd, 2018
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. def forgotPassword={
  2. if (params.email) {
  3. User user = User.findByEmail(params.email)
  4. if (user) {
  5. def password = randomService.generateRandomString(6)
  6. user.password = authenticateService.encodePassword(password)
  7. if (!user.save(flush:true)) {
  8. user.errors.each {
  9. log.error "err $it"
  10. }
  11. flash.message = message(code: "UserController.msg.forgot.error")
  12. } else {
  13. UserService.sendmail {
  14. to user.email
  15. subject message(code:"UserController.mail.forgot.subject" )
  16. body(view:"forgotPasswordEmail", model: [person:user, password:password])
  17. }
  18. flash.message = message(code:"UserController.msg.forgot", args:[user.email] )
  19. }
  20. } else {
  21. flash.message = message(code:"UserController.msg.forgot.unknown", args:[params.email])
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment