fix: use customer-spa for password reset page

Changed reset link URL from admin SPA to customer-spa:
- Old: /wp-admin/admin.php?page=woonoow#/reset-password?key=...
- New: /my-account#/reset-password?key=...

This fixes the login redirect issue - the customer-spa is publicly
accessible so users can reset their password without logging in first.

Added:
- customer-spa/src/pages/ResetPassword/index.tsx
- Route /reset-password in customer-spa App.tsx

EmailManager.php now:
- Uses wc_get_page_id('myaccount') to get my-account page URL
- Falls back to home_url if my-account page not found
This commit is contained in:
Dwindi Ramadhana
2026-01-03 17:09:00 +07:00
parent 316fcbf2f0
commit a98217897c
3 changed files with 313 additions and 4 deletions

View File

@@ -327,12 +327,19 @@ class EmailManager {
return $message; // Use WordPress default
}
// Build reset URL - use SPA route
$admin_url = admin_url('admin.php?page=woonoow');
// Build reset URL - use customer-facing SPA route on my-account page
// The my-account page loads the customer-spa which has the reset-password route
$myaccount_page_id = function_exists('wc_get_page_id') ? wc_get_page_id('myaccount') : 0;
if ($myaccount_page_id > 0) {
$myaccount_url = get_permalink($myaccount_page_id);
} else {
// Fallback to home URL if my-account page doesn't exist
$myaccount_url = home_url('/');
}
// Build SPA reset password URL with hash router format
// Format: /wp-admin/admin.php?page=woonoow#/reset-password?key=KEY&login=LOGIN
$reset_link = $admin_url . '#/reset-password?key=' . $key . '&login=' . rawurlencode($user_login);
// Format: /my-account/#/reset-password?key=KEY&login=LOGIN
$reset_link = rtrim($myaccount_url, '/') . '#/reset-password?key=' . $key . '&login=' . rawurlencode($user_login);
// Create a pseudo WC_Customer for template rendering
$customer = null;