google recaptcha

google recaptcha

Andreas S.Andreas S. Posts: 208Questions: 74Answers: 4
edited July 2019 in Editor

I have a provlem with the google reCaptcha v2. I have implementet it in a single Editor with this code:

    $( '#usr-signin' ).on( 'click', function() {
        auth
            .title( '<i class="fad fa-sign-in-alt txt-DarkCyan"></i> <span class="txt-DarkCyan bold">' + frmInfo.s_title + '</span>' )
            .buttons( [
                { label: frmInfo.login, action: function() { this.submit(
                    function() {
                        //window.location.href = 'index.php';
                    },
                    function( data ) {
                        this.close();
                        _PNotify( 'error', data['error']['errCode'] + ' ' + data['error']['errShort'], data['error']['icon'], data['error']['info'] );
                } ); }, className: 'btn-DarkCyan' },
                { label: frmInfo.cancel, action: function() { this.close(); } },
                { label: 'reset password', action: function() {

                } }
            ] ).edit();
        $( 'div.modal-dialog' ).removeClass( 'registration-dialog' ).addClass( 'login-dialog' );
        $( 'div.modal-content' ).removeClass( 'registration-content' ).addClass( 'login-content' );
        $( '<div class="g-recaptcha ml-100" data-sitekey="6LeD6g8Ucxxxxxxxxxxxxeded">' +
             '</div><script src="https://www.google.com/recaptcha/api.js"></script>' ).insertAfter( 'div.DTE_Field_Type_password' );
    } );

The captcha of google works, but if the submit button is pressed, the data will be sent no matter if captcha is true or not. How can I be sent before data check if the recaptcha is ok or not. Is there a simpler method? the security side does not help me here.

Andreas

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    Hi @Andreas S. ,

    I don't anything about the reCaptcha, but I'm guessing there's a method that confirms whether it's been validated or not. You could call that in initSubmit, run that validation test, and if it fails cancel the submit by returning false,

    Cheers,

    Colin

This discussion has been closed.