Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def forgotPassword = {
- if (!request.post) {
- // show the form
- return
- }
- //campo em branco
- String email = params.email
- def user = User.findByEmail(email)
- if (!email) {
- flash.error = message(code: 'Campo email em branco')
- redirect action: 'forgotPassword'
- return
- }else if (!user)
- {
- flash.error = message(code:'Email não encontrado')
- redirect action:'forgotPassword'
- return
- }else
- {
- def registrationCode = new RegistrationCode(user: user.username)
- registrationCode.save(flush:true)
- String url = generateLink('resetPassword', [t: registrationCode.token])
- //def conf = springSecurityUtils.securityConfig
- //def body = 'Usuario.:'+user.username+"""Senha.:"""+user.password
- def body = """Usuario: ${user.username}
- Link: <a href="${url}">clique aqui</a> """
- if (body.contains('$')) {
- body = evaluate(body, [user: user, url: url])
- }
- mailService.sendMail {
- to user.email
- from '[email protected]'
- subject 'Teste recuperar senha'
- html body.toString()
- }
- }
- [emailSent: true]
Advertisement
Add Comment
Please, Sign In to add comment