fix: Clear auth cookies before setting new ones + trigger wp_login action
This commit is contained in:
@@ -49,10 +49,14 @@ class AuthController {
|
||||
], 403 );
|
||||
}
|
||||
|
||||
// CRITICAL: Set auth cookie AND current user (as per WordPress best practices)
|
||||
// This ensures session is properly established for both standalone and wp-admin
|
||||
wp_set_auth_cookie( $user->ID, true, is_ssl() );
|
||||
// CRITICAL: Clear old cookies first, then set new ones
|
||||
// This ensures no stale session data interferes with the new login
|
||||
wp_clear_auth_cookie();
|
||||
wp_set_current_user( $user->ID );
|
||||
wp_set_auth_cookie( $user->ID, true );
|
||||
|
||||
// Trigger login action (same as wp-login.php)
|
||||
do_action( 'wp_login', $user->user_login, $user );
|
||||
|
||||
// Debug logging
|
||||
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
||||
|
||||
Reference in New Issue
Block a user