In my application I have the following setting in db.py:
auth.settings.logout_onlogout = lambda user: on_logout(auth,session)
auth.settings.logout_next=URL('cms','index')
on_logout(auth,session) is a function in a module which amongst others
contains
the following line of code:
auth.messages.logged_out='Succesvol uitgelogd, tot ziens %s' %(name)
This works well, the message is being displayed in a flash at cms/index
I tried something similar on login in db.py:
auth.settings.login_onlogin = lambda user: on_login(auth,session)
auth.settings.login_next=URL('cms','index')
However, auth.settings.login_onlogin, isn't a setting in web2py.
I changed this line to: auth.settings.login_onaccept= lambda user:
URL('cms','on_login')
I do no longer get the error but cms/onlogin isn't being executed. I get
cms/index
with a flash message: Logged in.
When i remove the setting: auth.settings.login_onlogin = lambda user:
on_login(auth,session)
and change auth.settings.login_next=URL('cms','index') to
auth.settings.login_next=URL('cms','on_login')
and in cms/on_login to cms/index, on_login is being executed but the
message isn't being displayed.
def on_login():
if auth.has_membership(ADMIN):
admin_menu()
session.memberships=[]
else:
session.memberships=db(db.auth_membership.user_id==auth.user.id).select(db.auth_membership.group_id).as_list()
standard_menu(auth.user.nodeID)
auth.messages.logged_in='Succesvol ingelogd, welkom %s' %(name)
session.alert='alert-success'
redirect(URL('index'))
When I change auth.messages.logged_in='Succesvol ingelogd, welkom %s'
%(name) to
session.flash='Succesvol ingelogd, welkom %s' %(name) The message is being
displayed correctly.
However, after a session has expired an the user logs in again, the message
is Logged in,
so in this case on_login is bypassed.
Why is logging in different from logging out?
Kind regards,
Annet
--
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.