google recaptcha

google recaptcha

Andreas S.Andreas S. Posts: 164Questions: 56Answers: 3
edited July 7 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: 5,853Questions: 0Answers: 1,012
    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

Sign In or Register to comment.