| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Yatra\Core\Handlers; |
| 6 |
|
| 7 |
use Yatra\Controllers\AuthController; |
| 8 |
|
| 9 |
/** |
| 10 |
* Pretty / plain routes for customer email verification links. |
| 11 |
*/ |
| 12 |
final class EmailVerificationPageHandler extends BasePageHandler |
| 13 |
{ |
| 14 |
/** |
| 15 |
* @param array<string, mixed> $route_data |
| 16 |
*/ |
| 17 |
public function handle(array $route_data): bool |
| 18 |
{ |
| 19 |
$token = isset($route_data['token']) ? (string) $route_data['token'] : ''; |
| 20 |
$token = preg_replace('/[^a-zA-Z0-9_-]/', '', $token) ?? ''; |
| 21 |
|
| 22 |
// AuthController::handleEmailVerification() performs wp_redirect/wp_die internally |
| 23 |
// and never returns to the template flow — so we don't queue a template via |
| 24 |
// PageContext. We still configure the page environment so any partial-failure |
| 25 |
// path that DOES return doesn't render the theme's 404. |
| 26 |
$this->setupPageEnvironment('singular', [ |
| 27 |
'title' => __('Email Verification', 'yatra'), |
| 28 |
'post_type' => 'page', |
| 29 |
'post_name' => $token !== '' ? 'verify-email/' . $token : 'verify-email', |
| 30 |
]); |
| 31 |
|
| 32 |
if ($token !== '') { |
| 33 |
$this->setQueryVars([ |
| 34 |
'yatra_verify_email' => $token, |
| 35 |
]); |
| 36 |
} |
| 37 |
|
| 38 |
AuthController::handleEmailVerification(); |
| 39 |
|
| 40 |
return true; |
| 41 |
} |
| 42 |
} |
| 43 |
|