i'm tried to do the same thing, but with no luck
e.g.
def login_attempts():
a = request.vars.username
b = db((db.auth_user.username == str(a))).select().first()
#login_attempts = 0
if b is not None:
#login_attempts += 1
session.login_attempts = (session.login_attempts or 0) + 1
#if login_attempts >= 3 :
#cache.ram('message', lambda: login_attempts, time_expire = 5)
#response.flash = login_attempts
#session.flash = login_attempts
#redirect(URL('default','test'))
if session.login_attempts >= 3 :
login_attempts = cache.ram('login_attempts', lambda: login_attempts,
time_expire = 5)
if not login_attempts:
session.forget(response)
#response.flash = session.login_attempts
#session.flash = session.login_attempts
#redirect(URL('default','test'))
auth.settings.login_onfail = login_attempts()
Error snapshot [image: help]
<https://127.0.0.1/admin/default/ticket/test/127.0.0.1.2015-04-22.18-24-38.0eca8a9e-2dd0-4c94-830c-c662062502b4#>
<type 'exceptions.NameError'>(free variable 'login_attempts' referenced
before assignment in enclosing scope)
is there a way to have login attempt lockout, that save in cache?
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.