Now I understand better. It does not work because the recaptcha has to
be inserted in a form=SQLFORM.... after it is defined but before it is
acceted. Since you are using form=auth.login() this function creates
the form and accepts in one step. It cannot be done without modifying
gluon tools. I have done it, so please try:
def login():
from gluon.tools import Recaptcha
auth.settings.login_catpcha = Recaptcha
(request,public_key,private_key)
form = auth.login()
form[0][-1][1].append(INPUT(_type='button',
_value='Cancel',_onclick="window.location='%s';"\
% URL(r=request,f='index')))
return dict(form=form)
On Dec 3, 8:53 pm, ed <[email protected]> wrote:
> Hi Massimo,
> The code does not display the recaptcha. Inserted code that displayed
> recaptcha but still failed to validate recaptcha words. I am baffled
> why the code works perfectly with the Registration and it doesn't with
> Login. Thanks again.
> Ed
>
> On Dec 3, 12:45 pm, mdipierro <[email protected]> wrote:
>
> > Does it work if you do it this way?
>
> > deflogin():
> > from gluon.tools importRecaptcha
> > auth.settings.catpcha =Recaptcha(request,public_key,private_key)
> > form = auth.login()
> > form[0][-1][1].append(INPUT(_type='button',
> > _value='Cancel',_onclick="window.location='%s';"\
> > % URL(r=request,f='index')))
> > return dict(form=form)
>
> > Massimo
>
> > On Dec 2, 9:46 pm, ed <[email protected]> wrote:
>
> > > Hi,
> > > I implementedRecaptchain my Registration app and works very well.
> > > But when I implemented the same inLoginit 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 importRecaptcha
> > > 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 importRecaptcha
> > > 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)
>
> > > deflogin():
> > > from gluon.tools importRecaptcha
> > > 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.