I have tried recaptcha v3 width auth login form but something is wrong. It 
seems to break the basic  auth validation methods.

Controller

def user():

    form = auth()
    my_captcha_element = TR(INPUT(_name='recaptcharesponse', value='', 
_type='hidden', _id='g-recaptcha-response'))
    form[0].insert(-1, my_captcha_element)
    if form.accepts(request.vars, session):
    #Comprobamos el CAPTCHA
        token = str(form.vars.recaptcharesponse)
        action = 'login'
        remoteip = str(request.env.remote_addr)
        score = 0.5 #elegimos el score que queremos
        capt = comprobar_captcha(token, action, remoteip, score) # A 
fucntion I've created to evaluate the captcha in server
        if capt == 'Falso':
            response.flash = T('Posible spam please try later.') 
            if session.counter >= 20:
                redirect(URL('errores','error',args='posiblebot'))
    return dict(form=form)

View

{{extend 'layout.html'}}

<div class="row"> 
  <div id="web2py_user_form" class="col-lg-6" 
style="background-color:white; margin: 0 auto 5px auto; box-shadow: 0 0 5px 
#a1a1a1; border-radius:5px;padding: 20px">
    <h2>
      {{=T('Sign Up') if request.args(0) == 'register' else T('Log In') if 
request.args(0) == 'login' else T(request.args(0).replace('_',' 
').title())}}
    </h2>
    {{=form}}

    {{if request.args(0)=='login' and not 'register' in 
auth.settings.actions_disabled:}}
    <a href="{{=URL('user/register')}}">{{=T('Register')}}</a>
    <br/>
    {{pass}}
    {{if request.args(0)=='login' and not 'retrieve_password' in 
auth.settings.actions_disabled:}}
    <a href="{{=URL('user/retrieve_password')}}">{{=T('Lost your 
password?')}}</a>
    {{pass}}
    {{if request.args(0)=='register':}}
    <a href="{{=URL('user/login')}}">{{=T('Login')}}</a>
    {{pass}}
  </div>
</div>



{{block page_js}}
<script>
    jQuery("#web2py_user_form input:visible:enabled:first").focus();
{{if request.args(0)=='register':}}
    web2py_validate_entropy(jQuery('#auth_user_password'),100);
{{elif request.args(0)=='change_password':}}
    web2py_validate_entropy(jQuery('#no_table_new_password'),100);
{{pass}}
</script>
{{end page_js}}

<script>
 grecaptcha.ready(function() {
      grecaptcha.execute('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 
{action:'login'}).then(function(token) {
          document.getElementById('g-recaptcha-response').value = token;
      });
  });
  </script>



-- 
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 web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/06b4ded4-53e2-45e8-b119-2ef42621f42b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to