Plugin Directory

Changeset 3247763


Ignore:
Timestamp:
02/27/2025 10:29:30 AM (13 months ago)
Author:
seplugins
Message:

invalid error colour change to red

File:
1 edited

Legend:

Unmodified
Added
Removed
  • two-step-factor-by-se/trunk/class-two-step-factor-core.php

    r3247588 r3247763  
    4343        self::destroy_current_session_for_user( $user );
    4444        wp_clear_auth_cookie();
    45         self::show_twoStB_factor_login( $user );
     45        $login_nonce =  wp_create_nonce('two_stb_factor_login_action');
     46        self::show_twoStB_factor_login( $user, $login_nonce );
    4647        exit;
    4748    }
     
    359360    }
    360361
    361     public static function show_twoStB_factor_login( $user ) {
     362    public static function show_twoStB_factor_login( $user, $nonce_req ) {
    362363        if ( ! $user ) {
    363364            $user = wp_get_current_user();
    364365        }
    365366
    366         if ( isset( $_REQUEST['_wpnonce'] ) ) {
     367        if ( isset( $nonce_req ) && !empty($nonce_req) ) {
    367368            // Remove slashes and sanitize the nonce value
    368             $nonce = sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) );
     369            $nonce = sanitize_text_field( wp_unslash( $nonce_req ) );
    369370            if ( ! wp_verify_nonce( $nonce, 'two_stb_factor_login_action' ) ) {
    370371                wp_die( esc_html__( 'Nonce verification failed.', 'two-step-factor-by-se' ) );
     
    373374            $login_nonce =  wp_create_nonce('wp-auth-nonce');
    374375            if ( ! $login_nonce ) {
    375             wp_die( esc_html__( 'Failed to create a login nonce.', 'two-step-factor-by-se' ) );
     376                wp_die( esc_html__( 'Failed to create a login nonce.', 'two-step-factor-by-se' ) );
    376377            }
    377378           
     
    454455        }
    455456    }
    456     public static function rememberme() {
     457    public static function rememberme( $login_nonce ) {
    457458        $rememberme = false;
    458459       
    459         if ( isset( $_REQUEST['_wpnonce'] ) ) {
     460        if ( isset( $login_nonce ) && !empty($login_nonce) ) {
    460461            // Remove slashes and sanitize the nonce value
    461             $nonce = sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) );
    462             if ( ! wp_verify_nonce( $nonce, 'two_stb_factor_login_action' ) ) {
     462            $nonce = sanitize_text_field( wp_unslash( $login_nonce ) );
     463            if ( ! wp_verify_nonce( $nonce, 'wp-auth-nonce' ) ) {
    463464                wp_die( esc_html__( 'Nonce verification failed.', 'two-step-factor-by-se' ) );
    464465            }
     
    489490        $interim_login       = isset( $_REQUEST['interim-login'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    490491
    491         $rememberme = intval( self::rememberme() );
     492        $rememberme = intval( self::rememberme( $login_nonce ) );
    492493
    493494        add_filter( 'login_display_language_dropdown', '__return_false' );
     
    596597                opacity: 0.5;
    597598            }
     599            #login_error{
     600                border: 1px solid #ff0000;
     601                padding: 10px;
     602                color: #ff0000;
     603                background: #fff;
     604                text-align: center;
     605            }
    598606        </style>
    599607        <script>
     
    610618                        function() {
    611619                            let value = this.value.replace(/\s/g, '');
    612 
    613620                            if ( ! spaceInserted && expectedLength && value.length === Math.floor( expectedLength / 2 ) ) {
    614621                                value += ' ';
     
    619626
    620627                            this.value = value;
    621                             console.log(value);
    622628                            // Auto-submit if it's the expected length.
    623629                            if ( expectedLength && value.replace( / /g, '' ).length == expectedLength ) {
    624630                                if ( undefined !== form.requestSubmit ) {
    625                                     form.requestSubmit();
    626                                     form.submit.disabled = "disabled";
     631                                    //form.requestSubmit();
     632                                    //form.submit.disabled = "disabled";
    627633                                }
    628634                            }
     
    702708                }
    703709                $error_message = 'Code is invalid.';
    704                 self::login_html( $user, $login_nonce, $redirect_to, $_POST, $error_message );
     710                self::login_html( $user, $login_nonce, $redirect_to, $error_message );
    705711                exit;
    706712            }else{
Note: See TracChangeset for help on using the changeset viewer.