Plugin Directory

Changeset 3826948


Ignore:
Timestamp:
11/26/2026 12:42:46 PM (less than one hour ago)
Author:
ravigadhiyawp
Message:

Security fixes and WordPress compatibility updates.

Location:
ajax-login-registration
Files:
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • ajax-login-registration/tags/1.0.5/README.txt

    r3277009 r3826948  
    33Tags: ajax login, ajax registration, ajax login registration, wp ajax login, wp ajax registration
    44Requires at least: 6.5
    5 Tested up to: 6.8
    6 Requires PHP: 7.2
    7 Stable tag: 1.0.4
     5Tested up to: 7.1
     6Requires PHP: 7.4
     7Stable tag: 1.0.5
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    … …  
    3232
    3333== Changelog ==
    34 = 1.0.1 =
    35 First release
     34= 1.0.5 =
     35* Security: Fixed password reset link poisoning vulnerability.
     36* Security: Fixed insecure password reset token validation.
     37* Security: Enforced server-side password reset token expiration.
     38* Security: Improved registration activation link security.
     39* Thanks to Muni Nitish Kumar Yaddala and the WPScan / Jetpack security team for reporting the vulnerabilities.
    3640
    37 = 1.0.2 =
     41= 1.0.4 =
    3842Test compatibility of plugin with latest version of WordPress
    3943
    … …  
    4145Add blueprints json file for plugin preview button
    4246
    43 = 1.0.4 =
     47= 1.0.2 =
    4448Test compatibility of plugin with latest version of WordPress
     49
     50= 1.0.1 =
     51First release
    4552
    4653== Upgrade Notice ==
  • ajax-login-registration/tags/1.0.5/admin/partials/ajax-login-registration-setting.php

    r2064898 r3826948  
    4444                                        <th scope="row"><label for="registration_email">Registration Email</label></th>
    4545                                        <td><?php wp_editor( get_option('registration_email'), 'registration_email', array( 'textarea_rows' => 8 ) ); ?>
    46                                         <p class="description">User get this email after registration. In the email template, you can use these mail-tags:<br /><code>[FIRSTNAME]</code> <code>[LASTNAME]</code> <code>[ACTIVATION_LINK]</code> <code>[USERNAME]</code></p></td>
     46                                        <p class="description">User get this email after registration. In the email template, you can use these mail-tags:<br /><code>[FIRSTNAME]</code> <code>[LASTNAME]</code> <code>[ACTIVATION_LINK]</code> <code>[USERNAME]</code> <code>[USER_EMAIL]</code></p></td>
    4747                                </tr>
    4848                                <tr>
  • ajax-login-registration/tags/1.0.5/ajax-login-registration.php

    r3277009 r3826948  
    77 * Plugin URI:        https://www.hktechnolab.com/
    88 * Description:       Ajax login & registration with email template confirmation
    9  * Version:           1.0.4
     9 * Version:           1.0.5
    1010 * Author:            Ravi Gadhiya
    1111 * Author URI:        https://profiles.wordpress.org/ravigadhiyawp
  • ajax-login-registration/tags/1.0.5/includes/class-ajax-login-registration.php

    r3260091 r3826948  
    5959                {       
    6060                        $this->plugin_name              = 'ajax-login-registration';
    61                         $this->version                  = '1.0.0';
     61                        $this->version                  = '1.0.5';
    6262                       
    6363                        $this->load_dependencies();
  • ajax-login-registration/tags/1.0.5/public/class-ajax-login-registration-public.php

    r3260091 r3826948  
    111111                }
    112112
    113                 //Generate Random String
    114                 public function generateRandomString($length = 20)
    115                 {
    116                         $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    117                         $charactersLength = strlen($characters);
    118                         $randomString = '';
    119                         for ($i = 0; $i < $length; $i++) {
    120                                 $randomString .= $characters[rand(0, $charactersLength - 1)];
    121                         }
    122                         return $randomString;
    123                 }
     113        // Resolve a published shortcode page using WordPress-owned URLs only.
     114        private function form_page_url( $field, $shortcode ) {
     115            $id = absint( $this->request_string( $_POST, $field ) );
     116            $page = get_post( $id );
     117            if ( ! $page || 'publish' !== $page->post_status || ! has_shortcode( $page->post_content, $shortcode ) ) {
     118                return '';
     119            }
     120            $url = get_permalink( $page );
     121            $site = wp_parse_url( home_url( '/' ) );
     122            $target = wp_parse_url( $url );
     123            if ( ! $url || empty( $target['host'] ) || empty( $site['host'] ) || strtolower( $target['host'] ) !== strtolower( $site['host'] ) || ( $target['scheme'] ?? '' ) !== ( $site['scheme'] ?? '' ) || ( $target['port'] ?? null ) !== ( $site['port'] ?? null ) ) {
     124                return '';
     125            }
     126            return $url;
     127        }
     128
     129        private function request_string( $source, $key ) {
     130            return isset( $source[$key] ) && is_string( $source[$key] ) ? wp_unslash( $source[$key] ) : '';
     131        }
     132
     133        public function generateRandomString( $length = 20 ) {
     134            return wp_generate_password( $length, false, false );
     135        }
     136
     137        // Shared by the reset form and AJAX handler. Legacy tokens are rejected.
     138        private function validate_reset_token( $user_id, $token ) {
     139            $user = get_user_by( 'id', $user_id );
     140            $issued = (int) get_user_meta( $user_id, 'alr_reset_issued', true );
     141            if ( ! $user || '' === $token || ! $issued || $issued > time() || time() - $issued >= HOUR_IN_SECONDS ) {
     142                return false;
     143            }
     144            $key_parts = explode( ':', $user->user_activation_key, 2 );
     145            if ( count( $key_parts ) !== 2 || ! ctype_digit( $key_parts[0] ) || time() - (int) $key_parts[0] >= HOUR_IN_SECONDS || (int) $key_parts[0] > time() ) {
     146                return false;
     147            }
     148            $verified = check_password_reset_key( $token, $user->user_login );
     149            return ! is_wp_error( $verified ) && (int) $verified->ID === (int) $user_id ? $verified : false;
     150        }
    124151
    125152                /**
    … …  
    141168                {
    142169                        $response                 = array();
    143                         $username                 = $_POST['username'];
    144                         $firstname                = $_POST['firstname'];
    145                         $lastname                 = $_POST['lastname'];
    146                         $email                    = $_POST['email'];
    147                         $signup_page      = $_POST['signup_page'];
    148                         $signup_nonce     = $_POST['signup_nonce'];
     170                        $username                 = $this->request_string( $_POST, 'username' );
     171                        $firstname                = $this->request_string( $_POST, 'firstname' );
     172                        $lastname                 = $this->request_string( $_POST, 'lastname' );
     173                        $email                    = $this->request_string( $_POST, 'email' );
     174                        $signup_page      = $this->form_page_url( 'signup_page', 'ajax-registration' );
     175                        $signup_nonce     = $this->request_string( $_POST, 'signup_nonce' );
    149176                         
    150177                        $response['errorStatus']                        = false;
    … …  
    156183                    $response['emailWarning']                   = false;
    157184
    158                     if ( !wp_verify_nonce( $signup_nonce, 'signup-nonce' ) ){
     185                    if ( ! $signup_page || !wp_verify_nonce( $signup_nonce, 'signup-nonce' ) ){
    159186                        $response['errorStatus'] = true;
    160187                        $response['hiddenError'] = true;
    … …  
    204231                    if($response['errorStatus'] == false){
    205232                        $new_user_id = wp_insert_user(array(
    206                                 'first_name' => ucfirst($firstname),
    207                                 'last_name'      => ucfirst($lastname),
     233                                'first_name' => sanitize_text_field( ucfirst($firstname) ),
     234                                'last_name'      => sanitize_text_field( ucfirst($lastname) ),
    208235                                'user_email' => $email,
    209236                                'user_login' => $username,
    … …  
    213240                        if( !is_wp_error($new_user_id) ){
    214241                                        if($new_user_id){
    215                                                 $activation_token               = $this->generateRandomString();
    216                                 $activation_page_url    = $signup_page.'?account-activation=yes&user_id='.$new_user_id.'&activation_token='.$activation_token;
    217                                                 $activation_link                = '<a href="'. $activation_page_url .'">Active Account</a>';
    218                                                 update_user_meta( $new_user_id, 'activation_token', $activation_token );
     242                                                $activation_token = $this->generateRandomString( 32 );
     243                                $activation_page_url    = add_query_arg( array( 'account-activation' => 'yes', 'user_id' => $new_user_id, 'activation_token' => $activation_token ), $signup_page );
     244                                                $activation_link                = '<a href="'. esc_url( $activation_page_url ) .'">Active Account</a>';
     245                                                update_user_meta( $new_user_id, 'activation_token', hash( 'sha256', $activation_token ) );
    219246                                                update_user_meta( $new_user_id, 'activation_token_time', time() );
    220247                                                update_user_meta( $new_user_id, 'is_activated', 0 );
    … …  
    237264                                                if(get_option('registration_email')){
    238265                                                        $tokens = array(
    239                                                                 'FIRSTNAME'             => ucfirst($firstname),
    240                                                                 'LASTNAME'              => ucfirst($lastname),
     266                                                                'FIRSTNAME'             => esc_html( ucfirst($firstname) ),
     267                                                                'LASTNAME'              => esc_html( ucfirst($lastname) ),
    241268                                                                'ACTIVATION_LINK'       => $activation_link,
     269                                                                'USERNAME'          => esc_html( $username ),
     270                                                                'USER_EMAIL'        => esc_html( $email ),
    242271                                                        );
    243272                                                        $mail_content .= $this->make_email_template( get_option('registration_email'), $tokens );
    244273                                                } else {
    245                                                         $mail_content .= '<p>Hello '.ucfirst($firstname).' '.ucfirst($lastname).',</p><p>Thanks you for your registration.</p><p>Please click below link to active account.</p><p><a href="'. $activation_page_url .'">Active Account</a></p>&nbsp;&nbsp;&nbsp;&nbsp;<p>Thanks &amp; Regards,<br/>'. get_bloginfo('name') .'</p>';
     274                                                        $mail_content .= '<p>Hello '.esc_html( ucfirst($firstname) ).' '.esc_html( ucfirst($lastname) ).',</p><p>Thanks you for your registration.</p><p>Please click below link to active account.</p><p><a href="'. esc_url( $activation_page_url ) .'">Active Account</a></p>&nbsp;&nbsp;&nbsp;&nbsp;<p>Thanks &amp; Regards,<br/>'. get_bloginfo('name') .'</p>';
    246275                                                }
    247276                                                $mail_content     .= $mail_footer;
    … …  
    255284                                                $admin_headers[]         = 'From: '. $admin_from;
    256285                                $admin_headers[]         = 'Content-Type: text/html; charset=UTF-8';
    257                                                 $admin_email_msg         = '<p>Hello Admin,</p><p>A new user is registered with follow details:</p><p><b>Name :</b> '.ucfirst($firstname).' '.ucfirst($lastname).'<br/><b>Email :</b> '.$email.'</p>&nbsp;&nbsp;&nbsp;&nbsp;<p>Thanks &amp; Regards,<br/>'. get_bloginfo('name') .'</p>';
     286                                                $admin_email_msg         = '<p>Hello Admin,</p><p>A new user is registered with follow details:</p><p><b>Name :</b> '.esc_html( ucfirst($firstname) ).' '.esc_html( ucfirst($lastname) ).'<br/><b>Email :</b> '.$email.'</p>&nbsp;&nbsp;&nbsp;&nbsp;<p>Thanks &amp; Regards,<br/>'. get_bloginfo('name') .'</p>';
    258287                                                $admin_mail_content  = $mail_header;
    259288                                                $admin_mail_content .= apply_filters('alr_change_admin_registration_email_msg', $admin_email_msg);
    … …  
    285314                {
    286315                        $response               = array();
    287                         $username               = $_POST['username'];
    288                         $password               = $_POST['password'];
    289                         $signin_nonce   = $_POST['signin_nonce'];
     316                        $username               = $this->request_string( $_POST, 'username' );
     317                        $password               = $this->request_string( $_POST, 'password' );
     318                        $signin_nonce   = $this->request_string( $_POST, 'signin_nonce' );
    290319                        $response['redirecturl']    = "";
    291320                        $response['errorStatus']        = false;
    … …  
    326355                                        } else {
    327356                                                $creds = array('user_login' => $user->data->user_login, 'user_password' => $password );
    328                                                 $user2 = wp_signon( $creds, false );
    329                                                 wp_set_auth_cookie($user2->ID, true, false );
    330                                                 do_action( 'wp_login', $user2->user_login );
     357                                                $creds['remember'] = true;
     358                        $user2 = wp_signon( $creds, is_ssl() );
    331359                                                if( !is_wp_error($user2) ) {
    332360                                                        $response['redirecturl']        = '';
    … …  
    353381                {
    354382                        $response                                       = array();
    355                         $username                                       = $_POST['username'];
    356                         $forgot_password_page           = $_POST['forgot_password_page'];
    357                         $forgot_password_nonce          = $_POST['forgot_password_nonce'];
     383                        $username                                       = $this->request_string( $_POST, 'username' );
     384                        $forgot_password_page = $this->form_page_url( 'forgot_password_page', 'ajax-login' );
     385                        $forgot_password_nonce          = $this->request_string( $_POST, 'forgot_password_nonce' );
    358386                        $response['redirecturl']    = '';
    359387                        $response['errorStatus']        = false;
    … …  
    363391                    $response['emailWarning']   = false;
    364392                                   
    365                     if ( ! wp_verify_nonce( $forgot_password_nonce, 'forgot-password' ) ){
     393                    if ( ! $forgot_password_page || ! wp_verify_nonce( $forgot_password_nonce, 'forgot-password' ) ){
    366394                        $response['errorStatus']        = true;
    367395                        $response['hiddenError']        = true;
    … …  
    383411                                }
    384412                                if ($user) {
    385                                         $currentPageUrl                 = strtok( $forgot_password_page, '?' );
    386                                         $activation_token               = $this->generateRandomString();
    387                                         $activation_page_url    = $currentPageUrl.'?action=rp&user_id='.$user->ID.'&rp_activation_token='.$activation_token;
    388                                         $activation_link                = '<a href="'. $activation_page_url .'">Reset Password</a>';
    389                                         update_user_meta( $user->ID, 'rp_activation_token', $activation_token );
    390                                         update_user_meta( $user->ID, 'rp_activation_time', time() );
    391                                         update_user_meta( $user->ID, 'rp_password_reset', 0 );
    392                                         $mail_header  = '<!DOCTYPE html>
     413                                        $currentPageUrl = $forgot_password_page;
     414                    $activation_token = get_password_reset_key( $user );
     415                    if ( is_wp_error( $activation_token ) ) {
     416                        $response['errorStatus'] = true;
     417                        $response['usersError'] = true;
     418                        $response['usersErrorMsg'] = __( 'Password reset is unavailable.', 'ajax-login-registration' );
     419                        wp_send_json( $response );
     420                    }
     421                    update_user_meta( $user->ID, 'alr_reset_issued', time() );
     422                    $activation_page_url = add_query_arg( array( 'action' => 'rp', 'user_id' => $user->ID, 'rp_activation_token' => $activation_token ), $currentPageUrl );
     423                    $activation_link = '<a href="' . esc_url( $activation_page_url ) . '">Reset Password</a>';
     424                    $mail_header  = '<!DOCTYPE html>
    393425                                                                        <html>
    394426                                                                        <head>
    … …  
    409441                                        if(get_option('reset_password_email')){
    410442                                                $tokens = array(
    411                                                         'FIRSTNAME'                     => ucfirst( $firstname ),
    412                                                         'LASTNAME'                      => ucfirst( $lastname ),
     443                                                        'FIRSTNAME'                     => esc_html( ucfirst( $firstname ) ),
     444                                                        'LASTNAME'                      => esc_html( ucfirst( $lastname ) ),
    413445                                                        'RESET_PASSWORD_LINK'   => $activation_link,
    414446                                                );
    415447                                                $mail_content .= $this->make_email_template( get_option('reset_password_email'), $tokens );
    416448                                        } else {
    417                                                 $mail_content .= '<p>Hello '.ucfirst($firstname).' '.ucfirst($lastname).',</p><p>You has requested a password reset for the '. get_bloginfo('name') .' account.</p><p>If you ingnore this message, password wonts be chnage. To reset your password, click on below link.</p><p><a href="'. $activation_page_url .'">Reset Password</a></p>&nbsp;&nbsp;&nbsp;&nbsp;<p>Thanks &amp; Regards,<br/>'. get_bloginfo('name') .'</p>';
     449                                                $mail_content .= '<p>Hello '.esc_html( ucfirst($firstname) ).' '.esc_html( ucfirst($lastname) ).',</p><p>You has requested a password reset for the '. get_bloginfo('name') .' account.</p><p>If you ingnore this message, password wonts be chnage. To reset your password, click on below link.</p><p><a href="'. esc_url( $activation_page_url ) .'">Reset Password</a></p>&nbsp;&nbsp;&nbsp;&nbsp;<p>Thanks &amp; Regards,<br/>'. get_bloginfo('name') .'</p>';
    418450                                        }
    419451                                        $mail_content     .= $mail_footer;
    … …  
    421453                                        /********* User Reset Email Template End *********/
    422454                                        if( $is_sent ){
    423                                                 $response['redirecturl'] = $currentPageUrl.'?checkemail=confirm';
     455                                                $response['redirecturl'] = add_query_arg( 'checkemail', 'confirm', $currentPageUrl );
    424456                                                $response['errorStatus'] = false;
    425457                                                $response['success'] = __('Check your email for the password reset link.', 'ajax-login-registration');
    … …  
    442474                {
    443475                        $response = array();
    444                         $user_password           = trim( $_POST['new_password']);
    445                         $user_repassword         = trim( $_POST['renew_password']);
    446                         $reset_password_nonce= trim( $_POST['reset_password_nonce']);
    447                         $user_id                         = trim( $_POST['user_id']);
    448                     $rp_activation_token = trim( $_POST['activation_token']);
    449                     $reset_password_page = trim( $_POST['reset_password_page']);
     476                        $user_password           = $this->request_string( $_POST, 'new_password' );
     477                        $user_repassword         = $this->request_string( $_POST, 'renew_password' );
     478                        $reset_password_nonce= $this->request_string( $_POST, 'reset_password_nonce' );
     479                        $user_id                         = $this->request_string( $_POST, 'user_id' );
     480                    $rp_activation_token = $this->request_string( $_POST, 'activation_token' );
     481                    $reset_password_page = $this->form_page_url( 'reset_password_page', 'ajax-login' );
    450482                       
    451483                        $response['redirecturl']    = "";
    … …  
    456488                    $response['errorRepassword']= false;
    457489                   
    458                     if ( ! wp_verify_nonce( $reset_password_nonce, 'reset-password' ) ){
     490                    if ( ! $reset_password_page || ! wp_verify_nonce( $reset_password_nonce, 'reset-password' ) ){
    459491                        $response['errorStatus'] = true;
    460492                        $response['hiddenError'] = true;
    … …  
    479511                        $response['errorRepassword'] = true;
    480512                        $response['errorRepasswordMsg'] = __('Confirm new password is required.', 'ajax-login-registration');
    481                     } else if( $user_repassword != $user_password){
     513                    } else if( $user_repassword !== $user_password){
    482514                                $response['errorStatus'] = true;
    483515                        $response['errorRepassword'] = true;
    … …  
    486518
    487519                        if($response['errorStatus'] == false){
    488                                 $currentPageUrl                 = strtok( $reset_password_page, '?' );
    489                                 $db_activation_token    = get_user_meta( $user_id, 'rp_activation_token', 1 );
    490                         if($db_activation_token == $rp_activation_token){
    491                             $pass_reset = get_user_meta( $user_id, 'rp_password_reset', 1 );
    492                             if( $pass_reset == 0 ) {
    493                                 $userdata = array(
    494                                     'ID'        =>  $user_id,
    495                                     'user_pass' =>  $user_password
    496                                 ); 
    497                                 $updated_user_id = wp_update_user($userdata);               
    498                                 if($user_id == $updated_user_id) {
    499                                     update_user_meta( $user_id, 'rp_password_reset', 1 );
    500                                     delete_user_meta($user_id, 'rp_activation_token');
    501                                     update_user_meta( $user_id, 'is_activated', 1 );
    502                                     $response['errorStatus'] = false;
    503                                     $response['redirecturl'] = $currentPageUrl.'?success=rp';
    504                                     $response['success']         = __('Your password has been reset.', 'ajax-login-registration');
    505                                 }
    506                             } else {
    507                                 $response['errorStatus'] = true;
    508                                 $response['usersError'] = true;
    509                                 $response['usersErrorMsg'] = __('Error: Please fill-up the form and submit it again', 'ajax-login-registration');
    510                             }
    511                         } else {
    512                             $response['errorStatus']    = true;
    513                             $response['usersError']     = true;
    514                             $response['redirecturl']    = $currentPageUrl.'?action=lostpassword&error=invalidkey';
    515                             $response['usersErrorMsg']  = __('Activation token is invalid.', 'ajax-login-registration');
    516                         }
     520                                $user = $this->validate_reset_token( absint( $user_id ), $rp_activation_token );
     521                if ( $user ) {
     522                    reset_password( $user, $user_password );
     523                    delete_user_meta( $user->ID, 'alr_reset_issued' );
     524                    delete_user_meta( $user->ID, 'rp_activation_token' );
     525                    delete_user_meta( $user->ID, 'rp_activation_time' );
     526                    delete_user_meta( $user->ID, 'rp_password_reset' );
     527                    $response['redirecturl'] = add_query_arg( 'success', 'rp', $reset_password_page );
     528                    $response['success'] = __( 'Your password has been reset.', 'ajax-login-registration' );
     529                } else {
     530                    $response['errorStatus'] = true;
     531                    $response['usersError'] = true;
     532                    $response['redirecturl'] = add_query_arg( array( 'action' => 'lostpassword', 'error' => 'invalidkey' ), $reset_password_page );
     533                    $response['usersErrorMsg'] = __( 'Activation token is invalid.', 'ajax-login-registration' );
     534                }
    517535                        }
    518536                        echo json_encode($response);
    519537                        exit;
    520538                }
    521 
    522                 public function test(){
    523                         echo 'Test';
    524                 }
    525539        }
  • ajax-login-registration/tags/1.0.5/public/js/ajax-login-registration-public.js

    r2064864 r3826948  
    189189                                                        }
    190190                                                } else {
     191                                                        console.log( 'response', response );
     192                                                       
    191193                                                        jQuery("#frm_user_signin").trigger('reset');
    192194                                                        jQuery('#frm_user_signin #responce-messages .success-msg').text(response.success);
    193195                                                        jQuery('#frm_user_signin #responce-messages').show();
    194196                                                        jQuery('#frm_user_signin #responce-messages .success-msg').css('display', 'inline-block');
    195                                                         //location.reload(true);
     197                                                        location.reload(true);
    196198                                                        //window.location = response.redirecturl;                               
    197199                                                }
  • ajax-login-registration/tags/1.0.5/public/templates/ajax-login-form.php

    r3277009 r3826948  
    33 * Ajax Login Public View
    44 */
    5 if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'){
    6         $pageUrl = "https";
    7 } else {
    8         $pageUrl = "http";
    9 }
    10 $pageUrl .= "://";
    11 $pageUrl .= $_SERVER['HTTP_HOST'];
    12 $pageUrl .= isset( $_SERVER['REDIRECT_URL'] ) ? rtrim($_SERVER['REDIRECT_URL'], '/') : '';
     5$page_id = get_queried_object_id();
     6$pageUrl = get_permalink( $page_id );
    137?>
     8<div class="form-container">
    149<?php
    1510if( isset($_REQUEST['action']) && $_REQUEST['action'] == 'lostpassword' ){ ?>
    16 <div class="form-container">
    1711        <form id="frm_forgot_password" method="post">
    1812                <?php
    … …  
    2822                </div>
    2923                <div class="form-group submit-button">
    30                         <input type="hidden" name="forgot_password_page" id="forgot_password_page" value="<?php echo $pageUrl; ?>" />
     24                        <input type="hidden" name="forgot_password_page" id="forgot_password_page" value="<?php echo esc_attr( $page_id ); ?>" />
    3125                        <input type="hidden" name="forgot_password_nonce" id="forgot_password_nonce" value="<?php echo wp_create_nonce('forgot-password'); ?>" />
    3226                        <button type="submit" class="btn"><?php echo __('Submit', 'ajax-login-registration'); ?></button>
    … …  
    4438                </div>
    4539        </form>
    46 </div>
    4740<?php } else if( isset($_REQUEST['action']) && $_REQUEST['action'] == 'rp' ){ ?>
    4841        <?php if( isset ( $_REQUEST['user_id']) && isset( $_REQUEST['rp_activation_token']) && !empty( $_REQUEST['user_id']) && !empty( $_REQUEST['rp_activation_token']) ){ ?>
    4942                <?php
    50                         $user_id = $_REQUEST['user_id'];
    51                         $activation_token = get_user_meta( $user_id, 'rp_activation_token', 1 );
    52                         $activation_time  = get_user_meta( $user_id, 'rp_activation_time', 1 );
    53                         $timeDifference   = time() - $activation_time;
    54                         if( ( $activation_token != $_REQUEST['rp_activation_token'] ) || ( $timeDifference > 3600 ) ){ ?>
    55                         <script type="text/javascript">window.location = "<?php echo $pageUrl; ?>?action=lostpassword&error=invalidkey";</script>
     43                        $user_id = absint( $this->request_string( $_GET, 'user_id' ) );
     44            $token = $this->request_string( $_GET, 'rp_activation_token' );
     45            if ( ! $this->validate_reset_token( $user_id, $token ) ) { ?>
     46                        <script type="text/javascript">window.location = <?php echo wp_json_encode( add_query_arg( array( 'action' => 'lostpassword', 'error' => 'invalidkey' ), $pageUrl ), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); ?>;</script>
    5647                        <?php
    5748                        } else { ?>
    58                                 <div class="form-container">
    59                                         <form id="frm_reset_password" method="post">
    60                                                 <div class="form-group">                                                       
    61                                                         <input type="password" name="new_password" id="new_password" class="form-control" placeholder="<?php echo __('New password', 'ajax-login-registration'); ?>">
    62                                                 </div>
    63                                                 <div class="form-group">
    64                                                         <input type="password" name="renew_password" id="renew_password" class="form-control" placeholder="<?php echo __('Confirm new password', 'ajax-login-registration'); ?>">
    65                                                 </div>
    66                                                 <div class="form-group submit-button">
    67                                                         <input type="hidden" name="rp_activation_token" id="rp_activation_token" value="<?php echo $_REQUEST['rp_activation_token']; ?>" />
    68                                                         <input type="hidden" name="user_id" id="user_id" value="<?php echo $_REQUEST['user_id']; ?>" />
    69                                                         <input type="hidden" name="reset_password_page" id="reset_password_page" value="<?php echo $pageUrl; ?>" />
    70                                                         <input type="hidden" name="reset_password_nonce" id="reset_password_nonce" value="<?php echo wp_create_nonce('reset-password'); ?>" />
    71                                                         <button type="submit" class="btn"><?php echo __('Submit', 'ajax-login-registration'); ?></button>
    72                                                         <span class="ajax-loader"></span>
    73                                                 </div>
    74                                                 <div id="responce-messages">
    75                                                         <div class="error-msg"></div>
    76                                                         <div class="success-msg"></div>
    77                                                 </div>
    78                                         </form>
    79                                 </div>
     49                                <form id="frm_reset_password" method="post">
     50                                        <div class="form-group">                                                       
     51                                                <input type="password" name="new_password" id="new_password" class="form-control" placeholder="<?php echo __('New password', 'ajax-login-registration'); ?>">
     52                                        </div>
     53                                        <div class="form-group">
     54                                                <input type="password" name="renew_password" id="renew_password" class="form-control" placeholder="<?php echo __('Confirm new password', 'ajax-login-registration'); ?>">
     55                                        </div>
     56                                        <div class="form-group submit-button">
     57                                                <input type="hidden" name="rp_activation_token" id="rp_activation_token" value="<?php echo esc_attr( $token ); ?>" />
     58                                                <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $user_id ); ?>" />
     59                                                <input type="hidden" name="reset_password_page" id="reset_password_page" value="<?php echo esc_attr( $page_id ); ?>" />
     60                                                <input type="hidden" name="reset_password_nonce" id="reset_password_nonce" value="<?php echo wp_create_nonce('reset-password'); ?>" />
     61                                                <button type="submit" class="btn"><?php echo __('Submit', 'ajax-login-registration'); ?></button>
     62                                                <span class="ajax-loader"></span>
     63                                        </div>
     64                                        <div id="responce-messages">
     65                                                <div class="error-msg"></div>
     66                                                <div class="success-msg"></div>
     67                                        </div>
     68                                </form>
    8069                        <?php }
    8170                ?>
    8271        <?php } ?>
    8372<?php } else { ?>
    84 <div class="form-container">
     73        <?php if ( is_user_logged_in() ) { ?>
     74                <p><?php echo __( 'You are already logged in.', 'ajax-login-registration'); ?> <a href="<?php echo esc_url( wp_logout_url( get_permalink() ) ); ?>"><?php echo __( 'Log out', 'ajax-login-registration'); ?></a></p>
     75        <?php } else { ?>
    8576        <form id="frm_user_signin" method="post">
    8677                <div class="form-group">
    … …  
    9586                ?>
    9687                <div class="form-group forgotten-pass">
    97                         <a href="?action=lostpassword"><?php echo $password_text; ?></a>
     88                        <a href="<?php echo esc_url( add_query_arg( 'action', 'lostpassword', $pageUrl ) ); ?>"><?php echo $password_text; ?></a>
    9889                </div>
    9990                <?php } ?>
    10091                <div class="form-group submit-button">
    101                         <input type="hidden" name="signin_page" id="signin_page" value="<?php echo $pageUrl; ?>" />
     92                        <input type="hidden" name="signin_page" id="signin_page" value="<?php echo esc_attr( $page_id ); ?>" />
    10293                        <input type="hidden" name="signin_nonce" id="signin_nonce" value="<?php echo wp_create_nonce('signin-nonce'); ?>" />
    10394                        <button type="submit" class="btn"><?php echo __('Submit', 'ajax-login-registration'); ?></button>
    … …  
    117108                </div>
    118109        </form>
     110        <?php } ?>
     111<?php } ?>
    119112</div>
    120 <?php } ?>
  • ajax-login-registration/tags/1.0.5/public/templates/ajax-registration-form.php

    r3277009 r3826948  
    33 * Ajax Registration Public View
    44 */     
    5 if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'){
    6         $pageUrl = "https";
    7 } else {
    8         $pageUrl = "http";
    9 }
    10 $pageUrl .= "://";
    11 $pageUrl .= $_SERVER['HTTP_HOST'];
    12 $pageUrl .= isset( $_SERVER['REDIRECT_URL'] ) ? rtrim($_SERVER['REDIRECT_URL'], '/') : '';
     5$page_id = get_queried_object_id();
     6$pageUrl = get_permalink( $page_id );
    137
    148if(isset($_GET['account-activation']) && $_GET['account-activation'] == 'yes' ){
    159        if( isset ( $_GET['user_id']) && isset( $_GET['activation_token']) && !empty( $_GET['user_id'])  && !empty( $_GET['activation_token']) ){
    16                 $user_id                        = $_GET['user_id'];
    17                 $activation_token       = get_user_meta( $user_id, 'activation_token', 1 );
    18                 $activation_time    = get_user_meta( $user_id, 'activation_token_time', 1 );
    19                 $timeDifference     = time() - $activation_time;
    20                 if( ($activation_token != $_GET['activation_token']) || ( $timeDifference > 3600 ) ){
     10                $user_id = absint( $this->request_string( $_GET, 'user_id' ) );
     11        $token = $this->request_string( $_GET, 'activation_token' );
     12        $activation_token = get_user_meta( $user_id, 'activation_token', true );
     13        $activation_time = (int) get_user_meta( $user_id, 'activation_token_time', true );
     14        if ( ! $user_id || '' === $token || ! is_string( $activation_token ) || ! hash_equals( $activation_token, hash( 'sha256', $token ) ) || ! $activation_time || $activation_time > time() || time() - $activation_time >= HOUR_IN_SECONDS || 'pending' !== get_user_meta( $user_id, 'user_active_status', true ) ) {
    2115                ?>
    2216                        <div>
    … …  
    3327                <?php
    3428                        } else {
    35                                 update_user_meta( $user_id, 'is_activated', 1 );
     29                                if ( ! delete_user_meta( $user_id, 'activation_token', $activation_token ) ) { return; }
     30                delete_user_meta( $user_id, 'activation_token_time' );
     31                update_user_meta( $user_id, 'is_activated', 1 );
    3632                                update_user_meta( $user_id, 'user_active_status', 'registered' );
    3733                                //delete_user_meta( $user_id, 'user_active_status');
    … …  
    6258                                if(get_option('activation_email')){
    6359                                        $tokens = array(
    64                                                 'FIRSTNAME'     => ucfirst( $firstname ),
    65                                                 'LASTNAME'      => ucfirst( $lastname ),
     60                                                'FIRSTNAME'     => esc_html( ucfirst( $firstname ) ),
     61                                                'LASTNAME'      => esc_html( ucfirst( $lastname ) ),
    6662                                                'NEW_PASSWORD'  => $user_password,
    6763                                        );
    6864                                        $mail_content .= $this->make_email_template( get_option('activation_email'), $tokens );
    6965                                } else {
    70                                         $mail_content .= '<p>Hello '.ucfirst($firstname).' '.ucfirst($lastname).',</p><p>Your account is activated successfully.</p><p>Your password is : '. $user_password .'</p>&nbsp;&nbsp;&nbsp;&nbsp;<p>Thanks &amp; Regards,<br/>'. get_bloginfo('name') .'</p>';
     66                                        $mail_content .= '<p>Hello '.esc_html( ucfirst($firstname) ).' '.esc_html( ucfirst($lastname) ).',</p><p>Your account is activated successfully.</p><p>Your password is : '. esc_html( $user_password ) .'</p>&nbsp;&nbsp;&nbsp;&nbsp;<p>Thanks &amp; Regards,<br/>'. get_bloginfo('name') .'</p>';
    7167                                }
    7268                                $mail_content     .= $mail_footer;
    … …  
    9187} else {
    9288?>
    93         <div class="form-container">
    94                 <form id="frm_user_signup" method="post">
    95                         <div class="form-group">
    96                                 <input type="text" name="signup_username" id="signup_username" class="form-control" placeholder="<?php echo __('Username', 'ajax-login-registration'); ?>">
    97                         </div>
    98                         <div class="form-group">
    99                                 <input type="text" name="signup_firstname" id="signup_firstname" class="form-control" placeholder="<?php echo __('First Name', 'ajax-login-registration'); ?>">
    100                         </div>
    101                         <div class="form-group">
    102                                 <input type="text" name="signup_lastname" id="signup_lastname" class="form-control" placeholder="<?php echo __('Last Name', 'ajax-login-registration'); ?>">
    103                         </div>
    104                         <div class="form-group">
    105                                 <input type="text" name="signup_email" id="signup_email" class="form-control" placeholder="<?php echo __('Email Address', 'ajax-login-registration'); ?>">
    106                         </div>
    107                         <div class="form-group submit-button">
    108                                 <input type="hidden" name="signup_page" id="signup_page" value="<?php echo $pageUrl; ?>" />
    109                                 <input type="hidden" name="signup_nonce" id="signup_nonce" value="<?php echo wp_create_nonce('signup-nonce'); ?>" />
    110                                 <button type="submit" class="btn"><?php echo __('Submit', 'ajax-login-registration'); ?></button>
    111                                 <span class="ajax-loader"></span>
    112                         </div>
    113                         <div id="responce-messages">
    114                                 <div class="error-msg"></div>
    115                                 <div class="success-msg"></div>
    116                                 <div class="warning-msg"></div>
    117                         </div>         
    118                 </form>
    119         </div>
     89        <?php if ( is_user_logged_in() ) { ?>
     90                <p><?php echo __( 'You are already logged in.', 'ajax-login-registration'); ?> <a href="<?php echo esc_url( wp_logout_url( get_permalink() ) ); ?>"><?php echo __( 'Log out', 'ajax-login-registration'); ?></a></p>
     91        <?php } else { ?>
     92                <div class="form-container">
     93                        <form id="frm_user_signup" method="post">
     94                                <div class="form-group">
     95                                        <input type="text" name="signup_username" id="signup_username" class="form-control" placeholder="<?php echo __('Username', 'ajax-login-registration'); ?>">
     96                                </div>
     97                                <div class="form-group">
     98                                        <input type="text" name="signup_firstname" id="signup_firstname" class="form-control" placeholder="<?php echo __('First Name', 'ajax-login-registration'); ?>">
     99                                </div>
     100                                <div class="form-group">
     101                                        <input type="text" name="signup_lastname" id="signup_lastname" class="form-control" placeholder="<?php echo __('Last Name', 'ajax-login-registration'); ?>">
     102                                </div>
     103                                <div class="form-group">
     104                                        <input type="text" name="signup_email" id="signup_email" class="form-control" placeholder="<?php echo __('Email Address', 'ajax-login-registration'); ?>">
     105                                </div>
     106                                <div class="form-group submit-button">
     107                                        <input type="hidden" name="signup_page" id="signup_page" value="<?php echo esc_attr( $page_id ); ?>" />
     108                                        <input type="hidden" name="signup_nonce" id="signup_nonce" value="<?php echo wp_create_nonce('signup-nonce'); ?>" />
     109                                        <button type="submit" class="btn"><?php echo __('Submit', 'ajax-login-registration'); ?></button>
     110                                        <span class="ajax-loader"></span>
     111                                </div>
     112                                <div id="responce-messages">
     113                                        <div class="error-msg"></div>
     114                                        <div class="success-msg"></div>
     115                                        <div class="warning-msg"></div>
     116                                </div>         
     117                        </form>
     118                </div>
     119        <?php } ?>
    120120<?php } ?>
  • ajax-login-registration/trunk/README.txt

    r3277009 r3826948  
    33Tags: ajax login, ajax registration, ajax login registration, wp ajax login, wp ajax registration
    44Requires at least: 6.5
    5 Tested up to: 6.8
    6 Requires PHP: 7.2
    7 Stable tag: 1.0.4
     5Tested up to: 7.1
     6Requires PHP: 7.4
     7Stable tag: 1.0.5
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    … …  
    3232
    3333== Changelog ==
    34 = 1.0.1 =
    35 First release
     34= 1.0.5 =
     35* Security: Fixed password reset link poisoning vulnerability.
     36* Security: Fixed insecure password reset token validation.
     37* Security: Enforced server-side password reset token expiration.
     38* Security: Improved registration activation link security.
     39* Thanks to Muni Nitish Kumar Yaddala and the WPScan / Jetpack security team for reporting the vulnerabilities.
    3640
    37 = 1.0.2 =
     41= 1.0.4 =
    3842Test compatibility of plugin with latest version of WordPress
    3943
    … …  
    4145Add blueprints json file for plugin preview button
    4246
    43 = 1.0.4 =
     47= 1.0.2 =
    4448Test compatibility of plugin with latest version of WordPress
     49
     50= 1.0.1 =
     51First release
    4552
    4653== Upgrade Notice ==
  • ajax-login-registration/trunk/admin/partials/ajax-login-registration-setting.php

    r2064898 r3826948  
    4444                                        <th scope="row"><label for="registration_email">Registration Email</label></th>
    4545                                        <td><?php wp_editor( get_option('registration_email'), 'registration_email', array( 'textarea_rows' => 8 ) ); ?>
    46                                         <p class="description">User get this email after registration. In the email template, you can use these mail-tags:<br /><code>[FIRSTNAME]</code> <code>[LASTNAME]</code> <code>[ACTIVATION_LINK]</code> <code>[USERNAME]</code></p></td>
     46                                        <p class="description">User get this email after registration. In the email template, you can use these mail-tags:<br /><code>[FIRSTNAME]</code> <code>[LASTNAME]</code> <code>[ACTIVATION_LINK]</code> <code>[USERNAME]</code> <code>[USER_EMAIL]</code></p></td>
    4747                                </tr>
    4848                                <tr>
  • ajax-login-registration/trunk/ajax-login-registration.php

    r3277009 r3826948  
    77 * Plugin URI:        https://www.hktechnolab.com/
    88 * Description:       Ajax login & registration with email template confirmation
    9  * Version:           1.0.4
     9 * Version:           1.0.5
    1010 * Author:            Ravi Gadhiya
    1111 * Author URI:        https://profiles.wordpress.org/ravigadhiyawp
  • ajax-login-registration/trunk/includes/class-ajax-login-registration.php

    r3260091 r3826948  
    5959                {       
    6060                        $this->plugin_name              = 'ajax-login-registration';
    61                         $this->version                  = '1.0.0';
     61                        $this->version                  = '1.0.5';
    6262                       
    6363                        $this->load_dependencies();
  • ajax-login-registration/trunk/public/class-ajax-login-registration-public.php

    r3260091 r3826948  
    111111                }
    112112
    113                 //Generate Random String
    114                 public function generateRandomString($length = 20)
    115                 {
    116                         $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    117                         $charactersLength = strlen($characters);
    118                         $randomString = '';
    119                         for ($i = 0; $i < $length; $i++) {
    120                                 $randomString .= $characters[rand(0, $charactersLength - 1)];
    121                         }
    122                         return $randomString;
    123                 }
     113        // Resolve a published shortcode page using WordPress-owned URLs only.
     114        private function form_page_url( $field, $shortcode ) {
     115            $id = absint( $this->request_string( $_POST, $field ) );
     116            $page = get_post( $id );
     117            if ( ! $page || 'publish' !== $page->post_status || ! has_shortcode( $page->post_content, $shortcode ) ) {
     118                return '';
     119            }
     120            $url = get_permalink( $page );
     121            $site = wp_parse_url( home_url( '/' ) );
     122            $target = wp_parse_url( $url );
     123            if ( ! $url || empty( $target['host'] ) || empty( $site['host'] ) || strtolower( $target['host'] ) !== strtolower( $site['host'] ) || ( $target['scheme'] ?? '' ) !== ( $site['scheme'] ?? '' ) || ( $target['port'] ?? null ) !== ( $site['port'] ?? null ) ) {
     124                return '';
     125            }
     126            return $url;
     127        }
     128
     129        private function request_string( $source, $key ) {
     130            return isset( $source[$key] ) && is_string( $source[$key] ) ? wp_unslash( $source[$key] ) : '';
     131        }
     132
     133        public function generateRandomString( $length = 20 ) {
     134            return wp_generate_password( $length, false, false );
     135        }
     136
     137        // Shared by the reset form and AJAX handler. Legacy tokens are rejected.
     138        private function validate_reset_token( $user_id, $token ) {
     139            $user = get_user_by( 'id', $user_id );
     140            $issued = (int) get_user_meta( $user_id, 'alr_reset_issued', true );
     141            if ( ! $user || '' === $token || ! $issued || $issued > time() || time() - $issued >= HOUR_IN_SECONDS ) {
     142                return false;
     143            }
     144            $key_parts = explode( ':', $user->user_activation_key, 2 );
     145            if ( count( $key_parts ) !== 2 || ! ctype_digit( $key_parts[0] ) || time() - (int) $key_parts[0] >= HOUR_IN_SECONDS || (int) $key_parts[0] > time() ) {
     146                return false;
     147            }
     148            $verified = check_password_reset_key( $token, $user->user_login );
     149            return ! is_wp_error( $verified ) && (int) $verified->ID === (int) $user_id ? $verified : false;
     150        }
    124151
    125152                /**
    … …  
    141168                {
    142169                        $response                 = array();
    143                         $username                 = $_POST['username'];
    144                         $firstname                = $_POST['firstname'];
    145                         $lastname                 = $_POST['lastname'];
    146                         $email                    = $_POST['email'];
    147                         $signup_page      = $_POST['signup_page'];
    148                         $signup_nonce     = $_POST['signup_nonce'];
     170                        $username                 = $this->request_string( $_POST, 'username' );
     171                        $firstname                = $this->request_string( $_POST, 'firstname' );
     172                        $lastname                 = $this->request_string( $_POST, 'lastname' );
     173                        $email                    = $this->request_string( $_POST, 'email' );
     174                        $signup_page      = $this->form_page_url( 'signup_page', 'ajax-registration' );
     175                        $signup_nonce     = $this->request_string( $_POST, 'signup_nonce' );
    149176                         
    150177                        $response['errorStatus']                        = false;
    … …  
    156183                    $response['emailWarning']                   = false;
    157184
    158                     if ( !wp_verify_nonce( $signup_nonce, 'signup-nonce' ) ){
     185                    if ( ! $signup_page || !wp_verify_nonce( $signup_nonce, 'signup-nonce' ) ){
    159186                        $response['errorStatus'] = true;
    160187                        $response['hiddenError'] = true;
    … …  
    204231                    if($response['errorStatus'] == false){
    205232                        $new_user_id = wp_insert_user(array(
    206                                 'first_name' => ucfirst($firstname),
    207                                 'last_name'      => ucfirst($lastname),
     233                                'first_name' => sanitize_text_field( ucfirst($firstname) ),
     234                                'last_name'      => sanitize_text_field( ucfirst($lastname) ),
    208235                                'user_email' => $email,
    209236                                'user_login' => $username,
    … …  
    213240                        if( !is_wp_error($new_user_id) ){
    214241                                        if($new_user_id){
    215                                                 $activation_token               = $this->generateRandomString();
    216                                 $activation_page_url    = $signup_page.'?account-activation=yes&user_id='.$new_user_id.'&activation_token='.$activation_token;
    217                                                 $activation_link                = '<a href="'. $activation_page_url .'">Active Account</a>';
    218                                                 update_user_meta( $new_user_id, 'activation_token', $activation_token );
     242                                                $activation_token = $this->generateRandomString( 32 );
     243                                $activation_page_url    = add_query_arg( array( 'account-activation' => 'yes', 'user_id' => $new_user_id, 'activation_token' => $activation_token ), $signup_page );
     244                                                $activation_link                = '<a href="'. esc_url( $activation_page_url ) .'">Active Account</a>';
     245                                                update_user_meta( $new_user_id, 'activation_token', hash( 'sha256', $activation_token ) );
    219246                                                update_user_meta( $new_user_id, 'activation_token_time', time() );
    220247                                                update_user_meta( $new_user_id, 'is_activated', 0 );
    … …  
    237264                                                if(get_option('registration_email')){
    238265                                                        $tokens = array(
    239                                                                 'FIRSTNAME'             => ucfirst($firstname),
    240                                                                 'LASTNAME'              => ucfirst($lastname),
     266                                                                'FIRSTNAME'             => esc_html( ucfirst($firstname) ),
     267                                                                'LASTNAME'              => esc_html( ucfirst($lastname) ),
    241268                                                                'ACTIVATION_LINK'       => $activation_link,
     269                                                                'USERNAME'          => esc_html( $username ),
     270                                                                'USER_EMAIL'        => esc_html( $email ),
    242271                                                        );
    243272                                                        $mail_content .= $this->make_email_template( get_option('registration_email'), $tokens );
    244273                                                } else {
    245                                                         $mail_content .= '<p>Hello '.ucfirst($firstname).' '.ucfirst($lastname).',</p><p>Thanks you for your registration.</p><p>Please click below link to active account.</p><p><a href="'. $activation_page_url .'">Active Account</a></p>&nbsp;&nbsp;&nbsp;&nbsp;<p>Thanks &amp; Regards,<br/>'. get_bloginfo('name') .'</p>';
     274                                                        $mail_content .= '<p>Hello '.esc_html( ucfirst($firstname) ).' '.esc_html( ucfirst($lastname) ).',</p><p>Thanks you for your registration.</p><p>Please click below link to active account.</p><p><a href="'. esc_url( $activation_page_url ) .'">Active Account</a></p>&nbsp;&nbsp;&nbsp;&nbsp;<p>Thanks &amp; Regards,<br/>'. get_bloginfo('name') .'</p>';
    246275                                                }
    247276                                                $mail_content     .= $mail_footer;
    … …  
    255284                                                $admin_headers[]         = 'From: '. $admin_from;
    256285                                $admin_headers[]         = 'Content-Type: text/html; charset=UTF-8';
    257                                                 $admin_email_msg         = '<p>Hello Admin,</p><p>A new user is registered with follow details:</p><p><b>Name :</b> '.ucfirst($firstname).' '.ucfirst($lastname).'<br/><b>Email :</b> '.$email.'</p>&nbsp;&nbsp;&nbsp;&nbsp;<p>Thanks &amp; Regards,<br/>'. get_bloginfo('name') .'</p>';
     286                                                $admin_email_msg         = '<p>Hello Admin,</p><p>A new user is registered with follow details:</p><p><b>Name :</b> '.esc_html( ucfirst($firstname) ).' '.esc_html( ucfirst($lastname) ).'<br/><b>Email :</b> '.$email.'</p>&nbsp;&nbsp;&nbsp;&nbsp;<p>Thanks &amp; Regards,<br/>'. get_bloginfo('name') .'</p>';
    258287                                                $admin_mail_content  = $mail_header;
    259288                                                $admin_mail_content .= apply_filters('alr_change_admin_registration_email_msg', $admin_email_msg);
    … …  
    285314                {
    286315                        $response               = array();
    287                         $username               = $_POST['username'];
    288                         $password               = $_POST['password'];
    289                         $signin_nonce   = $_POST['signin_nonce'];
     316                        $username               = $this->request_string( $_POST, 'username' );
     317                        $password               = $this->request_string( $_POST, 'password' );
     318                        $signin_nonce   = $this->request_string( $_POST, 'signin_nonce' );
    290319                        $response['redirecturl']    = "";
    291320                        $response['errorStatus']        = false;
    … …  
    326355                                        } else {
    327356                                                $creds = array('user_login' => $user->data->user_login, 'user_password' => $password );
    328                                                 $user2 = wp_signon( $creds, false );
    329                                                 wp_set_auth_cookie($user2->ID, true, false );
    330                                                 do_action( 'wp_login', $user2->user_login );
     357                                                $creds['remember'] = true;
     358                        $user2 = wp_signon( $creds, is_ssl() );
    331359                                                if( !is_wp_error($user2) ) {
    332360                                                        $response['redirecturl']        = '';
    … …  
    353381                {
    354382                        $response                                       = array();
    355                         $username                                       = $_POST['username'];
    356                         $forgot_password_page           = $_POST['forgot_password_page'];
    357                         $forgot_password_nonce          = $_POST['forgot_password_nonce'];
     383                        $username                                       = $this->request_string( $_POST, 'username' );
     384                        $forgot_password_page = $this->form_page_url( 'forgot_password_page', 'ajax-login' );
     385                        $forgot_password_nonce          = $this->request_string( $_POST, 'forgot_password_nonce' );
    358386                        $response['redirecturl']    = '';
    359387                        $response['errorStatus']        = false;
    … …  
    363391                    $response['emailWarning']   = false;
    364392                                   
    365                     if ( ! wp_verify_nonce( $forgot_password_nonce, 'forgot-password' ) ){
     393                    if ( ! $forgot_password_page || ! wp_verify_nonce( $forgot_password_nonce, 'forgot-password' ) ){
    366394                        $response['errorStatus']        = true;
    367395                        $response['hiddenError']        = true;
    … …  
    383411                                }
    384412                                if ($user) {
    385                                         $currentPageUrl                 = strtok( $forgot_password_page, '?' );
    386                                         $activation_token               = $this->generateRandomString();
    387                                         $activation_page_url    = $currentPageUrl.'?action=rp&user_id='.$user->ID.'&rp_activation_token='.$activation_token;
    388                                         $activation_link                = '<a href="'. $activation_page_url .'">Reset Password</a>';
    389                                         update_user_meta( $user->ID, 'rp_activation_token', $activation_token );
    390                                         update_user_meta( $user->ID, 'rp_activation_time', time() );
    391                                         update_user_meta( $user->ID, 'rp_password_reset', 0 );
    392                                         $mail_header  = '<!DOCTYPE html>
     413                                        $currentPageUrl = $forgot_password_page;
     414                    $activation_token = get_password_reset_key( $user );
     415                    if ( is_wp_error( $activation_token ) ) {
     416                        $response['errorStatus'] = true;
     417                        $response['usersError'] = true;
     418                        $response['usersErrorMsg'] = __( 'Password reset is unavailable.', 'ajax-login-registration' );
     419                        wp_send_json( $response );
     420                    }
     421                    update_user_meta( $user->ID, 'alr_reset_issued', time() );
     422                    $activation_page_url = add_query_arg( array( 'action' => 'rp', 'user_id' => $user->ID, 'rp_activation_token' => $activation_token ), $currentPageUrl );
     423                    $activation_link = '<a href="' . esc_url( $activation_page_url ) . '">Reset Password</a>';
     424                    $mail_header  = '<!DOCTYPE html>
    393425                                                                        <html>
    394426                                                                        <head>
    … …  
    409441                                        if(get_option('reset_password_email')){
    410442                                                $tokens = array(
    411                                                         'FIRSTNAME'                     => ucfirst( $firstname ),
    412                                                         'LASTNAME'                      => ucfirst( $lastname ),
     443                                                        'FIRSTNAME'                     => esc_html( ucfirst( $firstname ) ),
     444                                                        'LASTNAME'                      => esc_html( ucfirst( $lastname ) ),
    413445                                                        'RESET_PASSWORD_LINK'   => $activation_link,
    414446                                                );
    415447                                                $mail_content .= $this->make_email_template( get_option('reset_password_email'), $tokens );
    416448                                        } else {
    417                                                 $mail_content .= '<p>Hello '.ucfirst($firstname).' '.ucfirst($lastname).',</p><p>You has requested a password reset for the '. get_bloginfo('name') .' account.</p><p>If you ingnore this message, password wonts be chnage. To reset your password, click on below link.</p><p><a href="'. $activation_page_url .'">Reset Password</a></p>&nbsp;&nbsp;&nbsp;&nbsp;<p>Thanks &amp; Regards,<br/>'. get_bloginfo('name') .'</p>';
     449                                                $mail_content .= '<p>Hello '.esc_html( ucfirst($firstname) ).' '.esc_html( ucfirst($lastname) ).',</p><p>You has requested a password reset for the '. get_bloginfo('name') .' account.</p><p>If you ingnore this message, password wonts be chnage. To reset your password, click on below link.</p><p><a href="'. esc_url( $activation_page_url ) .'">Reset Password</a></p>&nbsp;&nbsp;&nbsp;&nbsp;<p>Thanks &amp; Regards,<br/>'. get_bloginfo('name') .'</p>';
    418450                                        }
    419451                                        $mail_content     .= $mail_footer;
    … …  
    421453                                        /********* User Reset Email Template End *********/
    422454                                        if( $is_sent ){
    423                                                 $response['redirecturl'] = $currentPageUrl.'?checkemail=confirm';
     455                                                $response['redirecturl'] = add_query_arg( 'checkemail', 'confirm', $currentPageUrl );
    424456                                                $response['errorStatus'] = false;
    425457                                                $response['success'] = __('Check your email for the password reset link.', 'ajax-login-registration');
    … …  
    442474                {
    443475                        $response = array();
    444                         $user_password           = trim( $_POST['new_password']);
    445                         $user_repassword         = trim( $_POST['renew_password']);
    446                         $reset_password_nonce= trim( $_POST['reset_password_nonce']);
    447                         $user_id                         = trim( $_POST['user_id']);
    448                     $rp_activation_token = trim( $_POST['activation_token']);
    449                     $reset_password_page = trim( $_POST['reset_password_page']);
     476                        $user_password           = $this->request_string( $_POST, 'new_password' );
     477                        $user_repassword         = $this->request_string( $_POST, 'renew_password' );
     478                        $reset_password_nonce= $this->request_string( $_POST, 'reset_password_nonce' );
     479                        $user_id                         = $this->request_string( $_POST, 'user_id' );
     480                    $rp_activation_token = $this->request_string( $_POST, 'activation_token' );
     481                    $reset_password_page = $this->form_page_url( 'reset_password_page', 'ajax-login' );
    450482                       
    451483                        $response['redirecturl']    = "";
    … …  
    456488                    $response['errorRepassword']= false;
    457489                   
    458                     if ( ! wp_verify_nonce( $reset_password_nonce, 'reset-password' ) ){
     490                    if ( ! $reset_password_page || ! wp_verify_nonce( $reset_password_nonce, 'reset-password' ) ){
    459491                        $response['errorStatus'] = true;
    460492                        $response['hiddenError'] = true;
    … …  
    479511                        $response['errorRepassword'] = true;
    480512                        $response['errorRepasswordMsg'] = __('Confirm new password is required.', 'ajax-login-registration');
    481                     } else if( $user_repassword != $user_password){
     513                    } else if( $user_repassword !== $user_password){
    482514                                $response['errorStatus'] = true;
    483515                        $response['errorRepassword'] = true;
    … …  
    486518
    487519                        if($response['errorStatus'] == false){
    488                                 $currentPageUrl                 = strtok( $reset_password_page, '?' );
    489                                 $db_activation_token    = get_user_meta( $user_id, 'rp_activation_token', 1 );
    490                         if($db_activation_token == $rp_activation_token){
    491                             $pass_reset = get_user_meta( $user_id, 'rp_password_reset', 1 );
    492                             if( $pass_reset == 0 ) {
    493                                 $userdata = array(
    494                                     'ID'        =>  $user_id,
    495                                     'user_pass' =>  $user_password
    496                                 ); 
    497                                 $updated_user_id = wp_update_user($userdata);               
    498                                 if($user_id == $updated_user_id) {
    499                                     update_user_meta( $user_id, 'rp_password_reset', 1 );
    500                                     delete_user_meta($user_id, 'rp_activation_token');
    501                                     update_user_meta( $user_id, 'is_activated', 1 );
    502                                     $response['errorStatus'] = false;
    503                                     $response['redirecturl'] = $currentPageUrl.'?success=rp';
    504                                     $response['success']         = __('Your password has been reset.', 'ajax-login-registration');
    505                                 }
    506                             } else {
    507                                 $response['errorStatus'] = true;
    508                                 $response['usersError'] = true;
    509                                 $response['usersErrorMsg'] = __('Error: Please fill-up the form and submit it again', 'ajax-login-registration');
    510                             }
    511                         } else {
    512                             $response['errorStatus']    = true;
    513                             $response['usersError']     = true;
    514                             $response['redirecturl']    = $currentPageUrl.'?action=lostpassword&error=invalidkey';
    515                             $response['usersErrorMsg']  = __('Activation token is invalid.', 'ajax-login-registration');
    516                         }
     520                                $user = $this->validate_reset_token( absint( $user_id ), $rp_activation_token );
     521                if ( $user ) {
     522                    reset_password( $user, $user_password );
     523                    delete_user_meta( $user->ID, 'alr_reset_issued' );
     524                    delete_user_meta( $user->ID, 'rp_activation_token' );
     525                    delete_user_meta( $user->ID, 'rp_activation_time' );
     526                    delete_user_meta( $user->ID, 'rp_password_reset' );
     527                    $response['redirecturl'] = add_query_arg( 'success', 'rp', $reset_password_page );
     528                    $response['success'] = __( 'Your password has been reset.', 'ajax-login-registration' );
     529                } else {
     530                    $response['errorStatus'] = true;
     531                    $response['usersError'] = true;
     532                    $response['redirecturl'] = add_query_arg( array( 'action' => 'lostpassword', 'error' => 'invalidkey' ), $reset_password_page );
     533                    $response['usersErrorMsg'] = __( 'Activation token is invalid.', 'ajax-login-registration' );
     534                }
    517535                        }
    518536                        echo json_encode($response);
    519537                        exit;
    520538                }
    521 
    522                 public function test(){
    523                         echo 'Test';
    524                 }
    525539        }
  • ajax-login-registration/trunk/public/js/ajax-login-registration-public.js

    r2064864 r3826948  
    189189                                                        }
    190190                                                } else {
     191                                                        console.log( 'response', response );
     192                                                       
    191193                                                        jQuery("#frm_user_signin").trigger('reset');
    192194                                                        jQuery('#frm_user_signin #responce-messages .success-msg').text(response.success);
    193195                                                        jQuery('#frm_user_signin #responce-messages').show();
    194196                                                        jQuery('#frm_user_signin #responce-messages .success-msg').css('display', 'inline-block');
    195                                                         //location.reload(true);
     197                                                        location.reload(true);
    196198                                                        //window.location = response.redirecturl;                               
    197199                                                }
  • ajax-login-registration/trunk/public/templates/ajax-login-form.php

    r3277009 r3826948  
    33 * Ajax Login Public View
    44 */
    5 if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'){
    6         $pageUrl = "https";
    7 } else {
    8         $pageUrl = "http";
    9 }
    10 $pageUrl .= "://";
    11 $pageUrl .= $_SERVER['HTTP_HOST'];
    12 $pageUrl .= isset( $_SERVER['REDIRECT_URL'] ) ? rtrim($_SERVER['REDIRECT_URL'], '/') : '';
     5$page_id = get_queried_object_id();
     6$pageUrl = get_permalink( $page_id );
    137?>
     8<div class="form-container">
    149<?php
    1510if( isset($_REQUEST['action']) && $_REQUEST['action'] == 'lostpassword' ){ ?>
    16 <div class="form-container">
    1711        <form id="frm_forgot_password" method="post">
    1812                <?php
    … …  
    2822                </div>
    2923                <div class="form-group submit-button">
    30                         <input type="hidden" name="forgot_password_page" id="forgot_password_page" value="<?php echo $pageUrl; ?>" />
     24                        <input type="hidden" name="forgot_password_page" id="forgot_password_page" value="<?php echo esc_attr( $page_id ); ?>" />
    3125                        <input type="hidden" name="forgot_password_nonce" id="forgot_password_nonce" value="<?php echo wp_create_nonce('forgot-password'); ?>" />
    3226                        <button type="submit" class="btn"><?php echo __('Submit', 'ajax-login-registration'); ?></button>
    … …  
    4438                </div>
    4539        </form>
    46 </div>
    4740<?php } else if( isset($_REQUEST['action']) && $_REQUEST['action'] == 'rp' ){ ?>
    4841        <?php if( isset ( $_REQUEST['user_id']) && isset( $_REQUEST['rp_activation_token']) && !empty( $_REQUEST['user_id']) && !empty( $_REQUEST['rp_activation_token']) ){ ?>
    4942                <?php
    50                         $user_id = $_REQUEST['user_id'];
    51                         $activation_token = get_user_meta( $user_id, 'rp_activation_token', 1 );
    52                         $activation_time  = get_user_meta( $user_id, 'rp_activation_time', 1 );
    53                         $timeDifference   = time() - $activation_time;
    54                         if( ( $activation_token != $_REQUEST['rp_activation_token'] ) || ( $timeDifference > 3600 ) ){ ?>
    55                         <script type="text/javascript">window.location = "<?php echo $pageUrl; ?>?action=lostpassword&error=invalidkey";</script>
     43                        $user_id = absint( $this->request_string( $_GET, 'user_id' ) );
     44            $token = $this->request_string( $_GET, 'rp_activation_token' );
     45            if ( ! $this->validate_reset_token( $user_id, $token ) ) { ?>
     46                        <script type="text/javascript">window.location = <?php echo wp_json_encode( add_query_arg( array( 'action' => 'lostpassword', 'error' => 'invalidkey' ), $pageUrl ), JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT ); ?>;</script>
    5647                        <?php
    5748                        } else { ?>
    58                                 <div class="form-container">
    59                                         <form id="frm_reset_password" method="post">
    60                                                 <div class="form-group">                                                       
    61                                                         <input type="password" name="new_password" id="new_password" class="form-control" placeholder="<?php echo __('New password', 'ajax-login-registration'); ?>">
    62                                                 </div>
    63                                                 <div class="form-group">
    64                                                         <input type="password" name="renew_password" id="renew_password" class="form-control" placeholder="<?php echo __('Confirm new password', 'ajax-login-registration'); ?>">
    65                                                 </div>
    66                                                 <div class="form-group submit-button">
    67                                                         <input type="hidden" name="rp_activation_token" id="rp_activation_token" value="<?php echo $_REQUEST['rp_activation_token']; ?>" />
    68                                                         <input type="hidden" name="user_id" id="user_id" value="<?php echo $_REQUEST['user_id']; ?>" />
    69                                                         <input type="hidden" name="reset_password_page" id="reset_password_page" value="<?php echo $pageUrl; ?>" />
    70                                                         <input type="hidden" name="reset_password_nonce" id="reset_password_nonce" value="<?php echo wp_create_nonce('reset-password'); ?>" />
    71                                                         <button type="submit" class="btn"><?php echo __('Submit', 'ajax-login-registration'); ?></button>
    72                                                         <span class="ajax-loader"></span>
    73                                                 </div>
    74                                                 <div id="responce-messages">
    75                                                         <div class="error-msg"></div>
    76                                                         <div class="success-msg"></div>
    77                                                 </div>
    78                                         </form>
    79                                 </div>
     49                                <form id="frm_reset_password" method="post">
     50                                        <div class="form-group">                                                       
     51                                                <input type="password" name="new_password" id="new_password" class="form-control" placeholder="<?php echo __('New password', 'ajax-login-registration'); ?>">
     52                                        </div>
     53                                        <div class="form-group">
     54                                                <input type="password" name="renew_password" id="renew_password" class="form-control" placeholder="<?php echo __('Confirm new password', 'ajax-login-registration'); ?>">
     55                                        </div>
     56                                        <div class="form-group submit-button">
     57                                                <input type="hidden" name="rp_activation_token" id="rp_activation_token" value="<?php echo esc_attr( $token ); ?>" />
     58                                                <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $user_id ); ?>" />
     59                                                <input type="hidden" name="reset_password_page" id="reset_password_page" value="<?php echo esc_attr( $page_id ); ?>" />
     60                                                <input type="hidden" name="reset_password_nonce" id="reset_password_nonce" value="<?php echo wp_create_nonce('reset-password'); ?>" />
     61                                                <button type="submit" class="btn"><?php echo __('Submit', 'ajax-login-registration'); ?></button>
     62                                                <span class="ajax-loader"></span>
     63                                        </div>
     64                                        <div id="responce-messages">
     65                                                <div class="error-msg"></div>
     66                                                <div class="success-msg"></div>
     67                                        </div>
     68                                </form>
    8069                        <?php }
    8170                ?>
    8271        <?php } ?>
    8372<?php } else { ?>
    84 <div class="form-container">
     73        <?php if ( is_user_logged_in() ) { ?>
     74                <p><?php echo __( 'You are already logged in.', 'ajax-login-registration'); ?> <a href="<?php echo esc_url( wp_logout_url( get_permalink() ) ); ?>"><?php echo __( 'Log out', 'ajax-login-registration'); ?></a></p>
     75        <?php } else { ?>
    8576        <form id="frm_user_signin" method="post">
    8677                <div class="form-group">
    … …  
    9586                ?>
    9687                <div class="form-group forgotten-pass">
    97                         <a href="?action=lostpassword"><?php echo $password_text; ?></a>
     88                        <a href="<?php echo esc_url( add_query_arg( 'action', 'lostpassword', $pageUrl ) ); ?>"><?php echo $password_text; ?></a>
    9889                </div>
    9990                <?php } ?>
    10091                <div class="form-group submit-button">
    101                         <input type="hidden" name="signin_page" id="signin_page" value="<?php echo $pageUrl; ?>" />
     92                        <input type="hidden" name="signin_page" id="signin_page" value="<?php echo esc_attr( $page_id ); ?>" />
    10293                        <input type="hidden" name="signin_nonce" id="signin_nonce" value="<?php echo wp_create_nonce('signin-nonce'); ?>" />
    10394                        <button type="submit" class="btn"><?php echo __('Submit', 'ajax-login-registration'); ?></button>
    … …  
    117108                </div>
    118109        </form>
     110        <?php } ?>
     111<?php } ?>
    119112</div>
    120 <?php } ?>
  • ajax-login-registration/trunk/public/templates/ajax-registration-form.php

    r3277009 r3826948  
    33 * Ajax Registration Public View
    44 */     
    5 if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'){
    6         $pageUrl = "https";
    7 } else {
    8         $pageUrl = "http";
    9 }
    10 $pageUrl .= "://";
    11 $pageUrl .= $_SERVER['HTTP_HOST'];
    12 $pageUrl .= isset( $_SERVER['REDIRECT_URL'] ) ? rtrim($_SERVER['REDIRECT_URL'], '/') : '';
     5$page_id = get_queried_object_id();
     6$pageUrl = get_permalink( $page_id );
    137
    148if(isset($_GET['account-activation']) && $_GET['account-activation'] == 'yes' ){
    159        if( isset ( $_GET['user_id']) && isset( $_GET['activation_token']) && !empty( $_GET['user_id'])  && !empty( $_GET['activation_token']) ){
    16                 $user_id                        = $_GET['user_id'];
    17                 $activation_token       = get_user_meta( $user_id, 'activation_token', 1 );
    18                 $activation_time    = get_user_meta( $user_id, 'activation_token_time', 1 );
    19                 $timeDifference     = time() - $activation_time;
    20                 if( ($activation_token != $_GET['activation_token']) || ( $timeDifference > 3600 ) ){
     10                $user_id = absint( $this->request_string( $_GET, 'user_id' ) );
     11        $token = $this->request_string( $_GET, 'activation_token' );
     12        $activation_token = get_user_meta( $user_id, 'activation_token', true );
     13        $activation_time = (int) get_user_meta( $user_id, 'activation_token_time', true );
     14        if ( ! $user_id || '' === $token || ! is_string( $activation_token ) || ! hash_equals( $activation_token, hash( 'sha256', $token ) ) || ! $activation_time || $activation_time > time() || time() - $activation_time >= HOUR_IN_SECONDS || 'pending' !== get_user_meta( $user_id, 'user_active_status', true ) ) {
    2115                ?>
    2216                        <div>
    … …  
    3327                <?php
    3428                        } else {
    35                                 update_user_meta( $user_id, 'is_activated', 1 );
     29                                if ( ! delete_user_meta( $user_id, 'activation_token', $activation_token ) ) { return; }
     30                delete_user_meta( $user_id, 'activation_token_time' );
     31                update_user_meta( $user_id, 'is_activated', 1 );
    3632                                update_user_meta( $user_id, 'user_active_status', 'registered' );
    3733                                //delete_user_meta( $user_id, 'user_active_status');
    … …  
    6258                                if(get_option('activation_email')){
    6359                                        $tokens = array(
    64                                                 'FIRSTNAME'     => ucfirst( $firstname ),
    65                                                 'LASTNAME'      => ucfirst( $lastname ),
     60                                                'FIRSTNAME'     => esc_html( ucfirst( $firstname ) ),
     61                                                'LASTNAME'      => esc_html( ucfirst( $lastname ) ),
    6662                                                'NEW_PASSWORD'  => $user_password,
    6763                                        );
    6864                                        $mail_content .= $this->make_email_template( get_option('activation_email'), $tokens );
    6965                                } else {
    70                                         $mail_content .= '<p>Hello '.ucfirst($firstname).' '.ucfirst($lastname).',</p><p>Your account is activated successfully.</p><p>Your password is : '. $user_password .'</p>&nbsp;&nbsp;&nbsp;&nbsp;<p>Thanks &amp; Regards,<br/>'. get_bloginfo('name') .'</p>';
     66                                        $mail_content .= '<p>Hello '.esc_html( ucfirst($firstname) ).' '.esc_html( ucfirst($lastname) ).',</p><p>Your account is activated successfully.</p><p>Your password is : '. esc_html( $user_password ) .'</p>&nbsp;&nbsp;&nbsp;&nbsp;<p>Thanks &amp; Regards,<br/>'. get_bloginfo('name') .'</p>';
    7167                                }
    7268                                $mail_content     .= $mail_footer;
    … …  
    9187} else {
    9288?>
    93         <div class="form-container">
    94                 <form id="frm_user_signup" method="post">
    95                         <div class="form-group">
    96                                 <input type="text" name="signup_username" id="signup_username" class="form-control" placeholder="<?php echo __('Username', 'ajax-login-registration'); ?>">
    97                         </div>
    98                         <div class="form-group">
    99                                 <input type="text" name="signup_firstname" id="signup_firstname" class="form-control" placeholder="<?php echo __('First Name', 'ajax-login-registration'); ?>">
    100                         </div>
    101                         <div class="form-group">
    102                                 <input type="text" name="signup_lastname" id="signup_lastname" class="form-control" placeholder="<?php echo __('Last Name', 'ajax-login-registration'); ?>">
    103                         </div>
    104                         <div class="form-group">
    105                                 <input type="text" name="signup_email" id="signup_email" class="form-control" placeholder="<?php echo __('Email Address', 'ajax-login-registration'); ?>">
    106                         </div>
    107                         <div class="form-group submit-button">
    108                                 <input type="hidden" name="signup_page" id="signup_page" value="<?php echo $pageUrl; ?>" />
    109                                 <input type="hidden" name="signup_nonce" id="signup_nonce" value="<?php echo wp_create_nonce('signup-nonce'); ?>" />
    110                                 <button type="submit" class="btn"><?php echo __('Submit', 'ajax-login-registration'); ?></button>
    111                                 <span class="ajax-loader"></span>
    112                         </div>
    113                         <div id="responce-messages">
    114                                 <div class="error-msg"></div>
    115                                 <div class="success-msg"></div>
    116                                 <div class="warning-msg"></div>
    117                         </div>         
    118                 </form>
    119         </div>
     89        <?php if ( is_user_logged_in() ) { ?>
     90                <p><?php echo __( 'You are already logged in.', 'ajax-login-registration'); ?> <a href="<?php echo esc_url( wp_logout_url( get_permalink() ) ); ?>"><?php echo __( 'Log out', 'ajax-login-registration'); ?></a></p>
     91        <?php } else { ?>
     92                <div class="form-container">
     93                        <form id="frm_user_signup" method="post">
     94                                <div class="form-group">
     95                                        <input type="text" name="signup_username" id="signup_username" class="form-control" placeholder="<?php echo __('Username', 'ajax-login-registration'); ?>">
     96                                </div>
     97                                <div class="form-group">
     98                                        <input type="text" name="signup_firstname" id="signup_firstname" class="form-control" placeholder="<?php echo __('First Name', 'ajax-login-registration'); ?>">
     99                                </div>
     100                                <div class="form-group">
     101                                        <input type="text" name="signup_lastname" id="signup_lastname" class="form-control" placeholder="<?php echo __('Last Name', 'ajax-login-registration'); ?>">
     102                                </div>
     103                                <div class="form-group">
     104                                        <input type="text" name="signup_email" id="signup_email" class="form-control" placeholder="<?php echo __('Email Address', 'ajax-login-registration'); ?>">
     105                                </div>
     106                                <div class="form-group submit-button">
     107                                        <input type="hidden" name="signup_page" id="signup_page" value="<?php echo esc_attr( $page_id ); ?>" />
     108                                        <input type="hidden" name="signup_nonce" id="signup_nonce" value="<?php echo wp_create_nonce('signup-nonce'); ?>" />
     109                                        <button type="submit" class="btn"><?php echo __('Submit', 'ajax-login-registration'); ?></button>
     110                                        <span class="ajax-loader"></span>
     111                                </div>
     112                                <div id="responce-messages">
     113                                        <div class="error-msg"></div>
     114                                        <div class="success-msg"></div>
     115                                        <div class="warning-msg"></div>
     116                                </div>         
     117                        </form>
     118                </div>
     119        <?php } ?>
    120120<?php } ?>
Note: See TracChangeset for help on using the changeset viewer.