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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user