You shouldn't be calling the callback function when setting the callback -- 
just put the function itself in the list -- web2py will call it at the 
appropriate point. Also, like the other Auth callback settings, 
login_onfail is a list, so you should append to it.

Instead of:

auth.settings.login_onfail = login_attempts()

it should be:

auth.settings.login_onfail.append(login_attempts)

Anthony

On Wednesday, April 22, 2015 at 9:33:32 AM UTC-4, 黄祥 wrote:
>
> it seems that the refresh login page, is count as login_onfail and 
> login_onvalidation in web2py default user login form.
> e.g.
> *models/db.py*
> def login_attempts():
> session.login_attempts = (session.login_attempts or 0) + 1
> if session.login_attempts >= 3 :
> #cache.ram('login_attempts', lambda: session.login_attempts, time_expire = 
> 5)
> response.flash = session.login_attempts
>
> #auth.settings.login_onfail = login_attempts()
> auth.settings.login_onvalidation = [login_attempts()]
>
> *views/default/user.html add response toolbar*
> {{=response.toolbar()}}
>
> 1. when i hit refresh https://127.0.0.1/test/default/user/login, the 
> session is added by 1
> 2. when i try to input the wrong login, the sessions added by 2 (1 added 
> by failure, n 1 added by refreshing the login form, i guess)
>
> trying to use login_onfail and login_onvalidation got the same result.
> is it normal behaviour, or i have the wrong steps?
>
> thanks and best regards,
> stifan
>

-- 
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.

Reply via email to