Hi,
I implemented Recaptcha in my Registration app and works very well.
But when I implemented the same in Login it does not check the "two
words" which Recaptch requires. The following is the code:
----------------------------------
-- Models --
db.py
auth.define_tables()
auth.settings.login='email:password'
from gluon.tools import Recaptcha
auth.settings.captcha = Recaptcha(request, '6LcUfwkAAAAAACt0m',
'6LcUfwkAAAAAAcUWLVn')
-- Controllers --
default.py
public_key = '6LcUfwkAAAAAACt0m'
private_key = '6LcUfwkAAAAAAPcUWLVn'
def user():
if request.args(0)=='reg_col':
from gluon.tools import Recaptcha
match_it = IS_EXPR('value==%s' % repr(request.vars.password),
error_message='passwords do not match')
form = SQLFORM.factory(
Field('emailad', 'emailad',requires=[IS_LENGTH
(maxsize=30,error_message='Maximum length 30 chars..'),IS_EMAIL(),
IS_NOT_IN_DB(db,'auth_user.email',error_message='Email address already
exist.')], required=True, label='* Email Address'),
Field('name', 'first',requires=[IS_LENGTH
(minsize=2,maxsize=30,error_message='Minimum length 2 and maximum
30.'),IS_UPPER()], label='* Name'),
Field('degree', 'degree',required=False,requires=IS_IN_DB
(db,'degreecurric.curcode','%(curcode)s'),label='* Degree Earned'),
Field('batchyr', 'batchyr', required=False,requires=IS_IN_DB
(db,'batchyr.moyear','%(moyear)s'),label='* Batch Year'),
Field('password', 'password',label='* Password', requires=
[IS_LENGTH(minsize=6,maxsize=30,error_message='Minimum length 6 and
maximum 30.')]),
Field('password_verify', 'password',label='* Password verify',
requires=match_it))
form[0].insert(-1, TR('', Recaptcha
(request,public_key,private_key))) [-1][1].append(INPUT
(_type='button',_value='Cancel',_onclick="window.location='%s';"%URL
(r=request,f='index')))
if form.accepts(request.vars, session):
emil = request.vars.emailad
name = request.vars.name
pasword = request.vars.password
password_verify = request.vars.password_verify
return dict(form=form)
def login():
from gluon.tools import Recaptcha
form = auth.login()
form[0].insert(-1, TR('', Recaptcha
(request,public_key,private_key)))
form[0][-1][1].append(INPUT
(_type='button',_value='Cancel',_onclick="window.location='%s';"%URL
(r=request,f='index')))
return dict(form=form)
--- Views --
user.html
{{if request.args(0)=='reg_col':}}
<h2>College Alumni Registration</h2>
<br>
{{=form}}
{{pass}}
- login.html -
<h2>Alumni Log-In</h2>
<br>
{{=form}}
{{pass}}
-----------------------------------------------------------------
I've reviewed the source code and tested various solutions but failed
to see what's wrong with it. Did I miss something?
Thanks a lot in advance.
Ed
--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.