Response flash message after email sent not working

閲覧: 26 回
最初の未読メッセージにスキップ

Maurice Waka

未読、
2022/03/04 5:15:542022/03/04
To: web2py-users
We have this user function, and when a user requests for password retrieval.
I would like to have a flash message displayed once the link is sent to user email.
So far the mail,successfully sends but how will the user know without the flash display message?
The code below doesn't seem to work.

def user():
    mail = auth.settings.mailer
    mail.settings.server = 'smtp.gmail.com:587'
    auth.messages.retrieve_username = 'Your user name: %(username)s'
    auth.messages.retrieve_username_subject = 'Username retrieval'
    auth.messages.reset_password_subject = 'Password Reset: '
    mail.settings.sender = 'my...@gmail.com'
    mail.settings.login = "my...@gmail.com:password"
    flash = dict(request_reset_password='Reset password email sent')
    auth.messages.email_sent = flash.get(request.args(0), auth.messages.email_sent)
    return dict(form=auth())

Carlos Correia

未読、
2022/03/07 21:40:032022/03/07
To: web...@googlegroups.com
Às 10:15 de 04/03/22, Maurice Waka escreveu:
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/1145f937-2c73-4ca7-b798-a2589b562ff3n%40googlegroups.com.

Instead of:

flash = dict(request_reset_password='Reset password email sent')
auth.messages.email_sent = flash.get(request.args(0), auth.messages.email_sent)

use:

response.flash = 'Reset password email sent'


http://web2py.com/books/default/chapter/29/07/forms-and-validators#Forms-and-redirection

-- 
Com os melhores cumprimentos,

Carlos Correia
=========================
MEMÓRIA PERSISTENTE
GSM:  917 157 146 (Signal, WhatsApp)
e-mail: ge...@memoriapersistente.pt
URL: http://www.memoriapersistente.pt
XMPP (Jabber): car...@memoriapersistente.pt
GnuPG: wwwkeys.eu.pgp.net
全員に返信
投稿者に返信
転送
新着メール 0 件