Changeset 3402233
- Timestamp:
- 11/25/2025 06:38:28 AM (4 months ago)
- Location:
- admin-safety-guard
- Files:
-
- 6 edited
- 1 copied
-
tags/1.1.3 (copied) (copied from admin-safety-guard/trunk)
-
tags/1.1.3/admin-safety-guard.php (modified) (2 diffs)
-
tags/1.1.3/app/Classes/Features/TwoFactorAuth.php (modified) (4 diffs)
-
tags/1.1.3/readme.txt (modified) (2 diffs)
-
trunk/admin-safety-guard.php (modified) (2 diffs)
-
trunk/app/Classes/Features/TwoFactorAuth.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
admin-safety-guard/tags/1.1.3/admin-safety-guard.php
r3401254 r3402233 4 4 Plugin URI: http://themepaste.com/product/themepaste-secure-admin-pro/ 5 5 Description: Secure your WordPress login with Admin safety guard to ensure secured access with limit login attempts, 2FA, reCaptcha, IP Blocking, Disable XML-RPC and activity tracking. 6 Version: 1.1. 26 Version: 1.1.3 7 7 Author: Themepaste Team 8 8 Author URI: http://themepaste.com/ … … 39 39 define( 'TPSA_PLUGIN_FILE', __FILE__ ); 40 40 define( 'TPSA_PREFIX', 'tpsa' ); 41 define( 'TPSA_PLUGIN_VERSION', '1.1. 2' );41 define( 'TPSA_PLUGIN_VERSION', '1.1.3' ); 42 42 define( 'TPSA_PLUGIN_DIRNAME', dirname( TPSA_PLUGIN_FILE ) ); 43 43 define( 'TPSA_PLUGIN_BASENAME', plugin_basename( TPSA_PLUGIN_FILE ) ); -
admin-safety-guard/tags/1.1.3/app/Classes/Features/TwoFactorAuth.php
r3401251 r3402233 46 46 47 47 if ( $this->is_enabled( $settings, 'otp-email' ) ) { 48 $this->action( 'login_form', [$this, 'check_otp_submission'] ); 48 // Process OTP submission as early as possible (before HTML output). 49 $this->action( 'login_init', [$this, 'check_otp_submission'] ); 50 51 // Render OTP UI on the login form. 49 52 $this->action( 'login_form', [$this, 'render_otp_input'] ); 53 54 // Intercept username/password login to send OTP first. 50 55 $this->filter( 'authenticate', [$this, 'intercept_login_with_otp'], 30, 3 ); 51 56 } … … 125 130 } 126 131 </style> 132 127 133 <div id="tpsa_otp_wrap"> 128 <label for="tpsa_otp_field"><?php echo esc_html__( 'One Time Password', 'tp-secure-plugin' ); ?></label> 134 <label for="tpsa_otp_field"> 135 <?php echo esc_html__( 'One Time Password', 'tp-secure-plugin' ); ?> 136 </label> 129 137 <input type="hidden" name="tpsa_user_id" value="<?php echo esc_attr( $user_id ); ?>"> 130 138 <input type="hidden" name="tpsa_otp_verify" value="1"> … … 133 141 <?php $this->sent_email_message( $user ); ?> 134 142 </div> 135 <button type="submit" id="tpsa_verify_btn"><?php echo esc_html__( 'Verify OTP', 'tp-secure-plugin' ); ?></button> 143 <button type="submit" id="tpsa_verify_btn"> 144 <?php echo esc_html__( 'Verify OTP', 'tp-secure-plugin' ); ?> 145 </button> 136 146 <?php 137 147 } 138 148 139 149 /** 140 * Check OTP submission on login form.150 * Check OTP submission on login (runs on login_init). 141 151 * 142 152 * @return void … … 156 166 $stored_data = get_user_meta( $user_id, '_tpsa_otp_code', true ); 157 167 $stored_otp = isset( $stored_data['otp'] ) ? $stored_data['otp'] : ''; 168 169 if ( $otp_input !== $stored_otp ) { 170 // Display error message above the form. 171 add_action( 172 'login_message', 173 function () { 174 echo '<div style="color:red; margin-bottom:10px;">' . 175 esc_html__( 'Invalid OTP. Please try again.', 'tp-secure-plugin' ) . 176 '</div>'; 177 } 178 ); 179 return; 180 } 181 182 // OTP is correct – now perform a proper WordPress login using wp_signon(). 183 $username = isset( $stored_data['username'] ) ? $stored_data['username'] : ''; 184 $password = isset( $stored_data['password'] ) ? $stored_data['password'] : ''; 158 185 $remember = !empty( $stored_data['remember'] ); 159 186 160 if ( $otp_input === $stored_otp ) { 161 // Clean up OTP data. 162 delete_user_meta( $user_id, '_tpsa_otp_code' ); 163 164 // Log user in with correct persistence. 165 wp_set_auth_cookie( $user_id, $remember ); 166 wp_set_current_user( $user_id ); 167 168 wp_redirect( admin_url() ); 169 exit; 170 } else { 171 // Display error message above the form. 172 add_action( 'login_message', function () { 173 echo '<div style="color:red; margin-bottom:10px;">' . esc_html__( 'Invalid OTP. Please try again.', 'tp-secure-plugin' ) . '</div>'; 174 } ); 175 } 187 // Clean up OTP data. 188 delete_user_meta( $user_id, '_tpsa_otp_code' ); 189 190 if ( empty( $username ) || empty( $password ) ) { 191 add_action( 192 'login_message', 193 function () { 194 echo '<div style="color:red; margin-bottom:10px;">' . 195 esc_html__( 'Login data missing. Please try logging in again.', 'tp-secure-plugin' ) . 196 '</div>'; 197 } 198 ); 199 return; 200 } 201 202 $creds = [ 203 'user_login' => $username, 204 'user_password' => $password, 205 'remember' => $remember, 206 ]; 207 208 // Let WordPress handle auth, cookies, tokens, Remember Me, etc. 209 $secure_cookie = is_ssl(); 210 $user = wp_signon( $creds, $secure_cookie ); 211 212 if ( is_wp_error( $user ) ) { 213 add_action( 214 'login_message', 215 function () { 216 echo '<div style="color:red; margin-bottom:10px;">' . 217 esc_html__( 'Login failed after OTP verification. Please try again.', 'tp-secure-plugin' ) . 218 '</div>'; 219 } 220 ); 221 return; 222 } 223 224 // Successful login, redirect to admin. 225 wp_safe_redirect( admin_url() ); 226 exit; 176 227 } 177 228 -
admin-safety-guard/tags/1.1.3/readme.txt
r3401254 r3402233 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.0 7 Stable tag: 1.1. 27 Stable tag: 1.1.3 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 150 150 == Changelog == 151 151 152 = 1.1.3 = 153 * Fixed an issue where OTP-verified logins could result in session cookies instead of persistent cookies. 154 * Refactored OTP verification to run earlier in the login flow via `login_init`. 155 * Updated the authentication process to use `wp_signon()` so WordPress handles Remember Me cookies correctly. 156 * Tested across multiple environments and browsers to confirm expected cookie expiration behavior. 157 * Minor improvements and stability adjustments. 158 159 = 1.1.3 = 160 * [fix] - Resolved persistent login cookie issue after OTP verification in certain environments. 161 * [fix] - OTP validation now runs earlier (`login_init`) to prevent headers already sent & session cookie fallback. 162 * [Improved] - Login is now completed through `wp_signon()` to let WordPress handle full cookie generation reliably. 163 * [Improved] - Tested across multiple environments and browsers for consistent persistent cookie behavior. 164 165 152 166 = 1.1.2 = 153 167 * [fix] - 2FA login cookie session issue when OTP verification completed. -
admin-safety-guard/trunk/admin-safety-guard.php
r3401254 r3402233 4 4 Plugin URI: http://themepaste.com/product/themepaste-secure-admin-pro/ 5 5 Description: Secure your WordPress login with Admin safety guard to ensure secured access with limit login attempts, 2FA, reCaptcha, IP Blocking, Disable XML-RPC and activity tracking. 6 Version: 1.1. 26 Version: 1.1.3 7 7 Author: Themepaste Team 8 8 Author URI: http://themepaste.com/ … … 39 39 define( 'TPSA_PLUGIN_FILE', __FILE__ ); 40 40 define( 'TPSA_PREFIX', 'tpsa' ); 41 define( 'TPSA_PLUGIN_VERSION', '1.1. 2' );41 define( 'TPSA_PLUGIN_VERSION', '1.1.3' ); 42 42 define( 'TPSA_PLUGIN_DIRNAME', dirname( TPSA_PLUGIN_FILE ) ); 43 43 define( 'TPSA_PLUGIN_BASENAME', plugin_basename( TPSA_PLUGIN_FILE ) ); -
admin-safety-guard/trunk/app/Classes/Features/TwoFactorAuth.php
r3401251 r3402233 46 46 47 47 if ( $this->is_enabled( $settings, 'otp-email' ) ) { 48 $this->action( 'login_form', [$this, 'check_otp_submission'] ); 48 // Process OTP submission as early as possible (before HTML output). 49 $this->action( 'login_init', [$this, 'check_otp_submission'] ); 50 51 // Render OTP UI on the login form. 49 52 $this->action( 'login_form', [$this, 'render_otp_input'] ); 53 54 // Intercept username/password login to send OTP first. 50 55 $this->filter( 'authenticate', [$this, 'intercept_login_with_otp'], 30, 3 ); 51 56 } … … 125 130 } 126 131 </style> 132 127 133 <div id="tpsa_otp_wrap"> 128 <label for="tpsa_otp_field"><?php echo esc_html__( 'One Time Password', 'tp-secure-plugin' ); ?></label> 134 <label for="tpsa_otp_field"> 135 <?php echo esc_html__( 'One Time Password', 'tp-secure-plugin' ); ?> 136 </label> 129 137 <input type="hidden" name="tpsa_user_id" value="<?php echo esc_attr( $user_id ); ?>"> 130 138 <input type="hidden" name="tpsa_otp_verify" value="1"> … … 133 141 <?php $this->sent_email_message( $user ); ?> 134 142 </div> 135 <button type="submit" id="tpsa_verify_btn"><?php echo esc_html__( 'Verify OTP', 'tp-secure-plugin' ); ?></button> 143 <button type="submit" id="tpsa_verify_btn"> 144 <?php echo esc_html__( 'Verify OTP', 'tp-secure-plugin' ); ?> 145 </button> 136 146 <?php 137 147 } 138 148 139 149 /** 140 * Check OTP submission on login form.150 * Check OTP submission on login (runs on login_init). 141 151 * 142 152 * @return void … … 156 166 $stored_data = get_user_meta( $user_id, '_tpsa_otp_code', true ); 157 167 $stored_otp = isset( $stored_data['otp'] ) ? $stored_data['otp'] : ''; 168 169 if ( $otp_input !== $stored_otp ) { 170 // Display error message above the form. 171 add_action( 172 'login_message', 173 function () { 174 echo '<div style="color:red; margin-bottom:10px;">' . 175 esc_html__( 'Invalid OTP. Please try again.', 'tp-secure-plugin' ) . 176 '</div>'; 177 } 178 ); 179 return; 180 } 181 182 // OTP is correct – now perform a proper WordPress login using wp_signon(). 183 $username = isset( $stored_data['username'] ) ? $stored_data['username'] : ''; 184 $password = isset( $stored_data['password'] ) ? $stored_data['password'] : ''; 158 185 $remember = !empty( $stored_data['remember'] ); 159 186 160 if ( $otp_input === $stored_otp ) { 161 // Clean up OTP data. 162 delete_user_meta( $user_id, '_tpsa_otp_code' ); 163 164 // Log user in with correct persistence. 165 wp_set_auth_cookie( $user_id, $remember ); 166 wp_set_current_user( $user_id ); 167 168 wp_redirect( admin_url() ); 169 exit; 170 } else { 171 // Display error message above the form. 172 add_action( 'login_message', function () { 173 echo '<div style="color:red; margin-bottom:10px;">' . esc_html__( 'Invalid OTP. Please try again.', 'tp-secure-plugin' ) . '</div>'; 174 } ); 175 } 187 // Clean up OTP data. 188 delete_user_meta( $user_id, '_tpsa_otp_code' ); 189 190 if ( empty( $username ) || empty( $password ) ) { 191 add_action( 192 'login_message', 193 function () { 194 echo '<div style="color:red; margin-bottom:10px;">' . 195 esc_html__( 'Login data missing. Please try logging in again.', 'tp-secure-plugin' ) . 196 '</div>'; 197 } 198 ); 199 return; 200 } 201 202 $creds = [ 203 'user_login' => $username, 204 'user_password' => $password, 205 'remember' => $remember, 206 ]; 207 208 // Let WordPress handle auth, cookies, tokens, Remember Me, etc. 209 $secure_cookie = is_ssl(); 210 $user = wp_signon( $creds, $secure_cookie ); 211 212 if ( is_wp_error( $user ) ) { 213 add_action( 214 'login_message', 215 function () { 216 echo '<div style="color:red; margin-bottom:10px;">' . 217 esc_html__( 'Login failed after OTP verification. Please try again.', 'tp-secure-plugin' ) . 218 '</div>'; 219 } 220 ); 221 return; 222 } 223 224 // Successful login, redirect to admin. 225 wp_safe_redirect( admin_url() ); 226 exit; 176 227 } 177 228 -
admin-safety-guard/trunk/readme.txt
r3401254 r3402233 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.0 7 Stable tag: 1.1. 27 Stable tag: 1.1.3 8 8 License: GPLv3 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 150 150 == Changelog == 151 151 152 = 1.1.3 = 153 * Fixed an issue where OTP-verified logins could result in session cookies instead of persistent cookies. 154 * Refactored OTP verification to run earlier in the login flow via `login_init`. 155 * Updated the authentication process to use `wp_signon()` so WordPress handles Remember Me cookies correctly. 156 * Tested across multiple environments and browsers to confirm expected cookie expiration behavior. 157 * Minor improvements and stability adjustments. 158 159 = 1.1.3 = 160 * [fix] - Resolved persistent login cookie issue after OTP verification in certain environments. 161 * [fix] - OTP validation now runs earlier (`login_init`) to prevent headers already sent & session cookie fallback. 162 * [Improved] - Login is now completed through `wp_signon()` to let WordPress handle full cookie generation reliably. 163 * [Improved] - Tested across multiple environments and browsers for consistent persistent cookie behavior. 164 165 152 166 = 1.1.2 = 153 167 * [fix] - 2FA login cookie session issue when OTP verification completed.
Note: See TracChangeset
for help on using the changeset viewer.