CHANGE THE LOGIN FLASH MESSAGE

32 views
Skip to first unread message

Ayron Rangel

unread,
Jun 18, 2018, 9:48:04 AM6/18/18
to web2py-users
Guys,

How do I change the response.flash message when I log in?

Every time when I'm login, appears just "Logged In", i want to change this message to Welcome ' username'. 

Regards,
Ayron Rangel

Anthony

unread,
Jun 18, 2018, 10:46:50 AM6/18/18
to web2py-users
You can customize the login message via auth.messages.logged_in. However, you won't be able to include the username in that message because it will not be known until after the login. Instead, you could append a callback function to the auth.settings.login_onaccept list, and in that function, you could explicitly set:

session.flash = 'Welcome %s' % auth.user.username

Anthony

Ayron Rangel

unread,
Jun 18, 2018, 1:42:08 PM6/18/18
to web...@googlegroups.com

Anthony,

Will I use the auth.messages.logged_in in the model? or in the view??

黄祥

unread,
Jun 18, 2018, 7:52:40 PM6/18/18
to web2py-users
usually auth.settings is declare in models e.g. models/db.py

best regards,
stifan
Reply all
Reply to author
Forward
0 new messages