fix: Trust PHP auth check, skip redundant REST API call
This commit is contained in:
@@ -85,9 +85,18 @@ class AuthController {
|
||||
* @return WP_REST_Response Response object
|
||||
*/
|
||||
public static function check(): WP_REST_Response {
|
||||
if ( ! is_user_logged_in() ) {
|
||||
$is_logged_in = is_user_logged_in();
|
||||
|
||||
// Debug logging
|
||||
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
||||
error_log( '[AuthController::check] is_user_logged_in: ' . ( $is_logged_in ? 'true' : 'false' ) );
|
||||
error_log( '[AuthController::check] Cookies: ' . print_r( $_COOKIE, true ) );
|
||||
}
|
||||
|
||||
if ( ! $is_logged_in ) {
|
||||
return new WP_REST_Response( [
|
||||
'authenticated' => false,
|
||||
'debug' => 'Not logged in',
|
||||
], 200 );
|
||||
}
|
||||
|
||||
@@ -98,6 +107,7 @@ class AuthController {
|
||||
return new WP_REST_Response( [
|
||||
'authenticated' => false,
|
||||
'message' => __( 'Insufficient permissions', 'woonoow' ),
|
||||
'debug' => 'No manage_woocommerce permission',
|
||||
], 200 );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user