Hello,
I am quiet new to Web2py and I am having a hard time with the Auth events
handlers.
I am trying to check if a user tried to login before hitting the page but I
can't get to know it.
This is my index Controller:
def index():
return dict(form=auth.login())
In the view I have a carrousel, with the loggin in one of the pane (but no
visible at first load of the page).
What I am trying to do is:
In case someone tries to login from inside the carrousel and didn't get
through, when the Auth redirects back to my index, get to know it and set
the carrousel back on the loggin form with a custom message saying that
there was an error.
In the documentation I see 2 useful callback for that but they don't seem
to work in my scenario (on_failed_authorization and
on_failed_authorization):
Here is wht I set in my db.py:
---
def failedAuthHandler():
session.log_message = "error"
def attempLogin():
session.try_login = True
auth.settings.on_failed_authorization = failedAuthHandler()
auth.settings.login_onvalidation = attempLogin()
---
What happens in my index view is this:
Everytime (even when the user doesn't try to login) I get:
session.log_message = "error"
So I can't use something like: if session.log_message == 'error' set the
carrousel and put an error message.
I then tried the login_onvalidation callback to set a session variable when
the user is trying to login, but it get set each time (refresh of the page)
to True.
The "login_onvalidation" get triggerd even when not submiting the login
form....
Any help would be greatly appreciated!
Thanks!
Sebastian.
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.