| 1 |
<?php |
| 2 |
/** |
| 3 |
* Booking Authentication Partial |
| 4 |
* Shows login/registration forms when user is not logged in |
| 5 |
* |
| 6 |
* @package Yatra |
| 7 |
*/ |
| 8 |
|
| 9 |
// Prevent direct access |
| 10 |
if (!defined('ABSPATH')) { |
| 11 |
exit; |
| 12 |
} |
| 13 |
|
| 14 |
global $booking; |
| 15 |
$trip = $booking->trip ?? null; |
| 16 |
|
| 17 |
// Account registration is gated by the same setting the backend enforces |
| 18 |
// (AuthController rejects registration when this is off). When it's disabled we |
| 19 |
// hide the Register tab/form and the "Register now" switch so customers only |
| 20 |
// see the Login option. |
| 21 |
$registration_enabled = class_exists('\\Yatra\\Services\\SettingsService') |
| 22 |
? \Yatra\Services\SettingsService::isEnabled('customer_registration') |
| 23 |
: true; |
| 24 |
?> |
| 25 |
|
| 26 |
<div class="yatra-booking-auth"> |
| 27 |
<!-- Tab Navigation --> |
| 28 |
<div class="yatra-auth-tabs"> |
| 29 |
<button type="button" class="yatra-auth-tab active" data-tab="login"> |
| 30 |
<svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 31 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1"/> |
| 32 |
</svg> |
| 33 |
<?php esc_html_e('Login', 'yatra'); ?> |
| 34 |
</button> |
| 35 |
<?php if ($registration_enabled) : ?> |
| 36 |
<button type="button" class="yatra-auth-tab" data-tab="register"> |
| 37 |
<svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 38 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18 9v3m0 0v3m0-3h3m-3 0h-3m-2-5a4 4 0 11-8 0 4 4 0 018 0zM3 20a6 6 0 0112 0v1H3v-1z"/> |
| 39 |
</svg> |
| 40 |
<?php esc_html_e('Register', 'yatra'); ?> |
| 41 |
</button> |
| 42 |
<?php endif; ?> |
| 43 |
</div> |
| 44 |
|
| 45 |
<!-- Login Form --> |
| 46 |
<div class="yatra-auth-content" id="yatra-auth-login"> |
| 47 |
<div class="yatra-auth-header"> |
| 48 |
<h2><?php esc_html_e('Welcome Back', 'yatra'); ?></h2> |
| 49 |
<p><?php esc_html_e('Please login to continue with your booking.', 'yatra'); ?></p> |
| 50 |
</div> |
| 51 |
|
| 52 |
<?php if (isset($_GET['email_verified']) && $_GET['email_verified'] === '1') : ?> |
| 53 |
<div class="yatra-auth-message success" style="display: block; margin-bottom: 20px;"> |
| 54 |
<?php esc_html_e('Your email has been verified successfully! You can now log in.', 'yatra'); ?> |
| 55 |
</div> |
| 56 |
<?php endif; ?> |
| 57 |
|
| 58 |
<form id="yatra-login-form" class="yatra-auth-form" method="post"> |
| 59 |
|
| 60 |
<div class="yatra-form-group"> |
| 61 |
<label for="yatra-login-email"> |
| 62 |
<?php esc_html_e('Email or Username', 'yatra'); ?> |
| 63 |
<span class="required">*</span> |
| 64 |
</label> |
| 65 |
<div class="yatra-input-wrapper"> |
| 66 |
<svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 67 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/> |
| 68 |
</svg> |
| 69 |
<input type="text" id="yatra-login-email" name="log" required placeholder="<?php esc_attr_e('Enter your email or username', 'yatra'); ?>"> |
| 70 |
</div> |
| 71 |
</div> |
| 72 |
|
| 73 |
<div class="yatra-form-group"> |
| 74 |
<label for="yatra-login-password"> |
| 75 |
<?php esc_html_e('Password', 'yatra'); ?> |
| 76 |
<span class="required">*</span> |
| 77 |
</label> |
| 78 |
<div class="yatra-input-wrapper"> |
| 79 |
<svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 80 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"/> |
| 81 |
</svg> |
| 82 |
<input type="password" id="yatra-login-password" name="pwd" required placeholder="<?php esc_attr_e('Enter your password', 'yatra'); ?>"> |
| 83 |
<button type="button" class="yatra-toggle-password" tabindex="-1"> |
| 84 |
<svg class="eye-open" width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 85 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/> |
| 86 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/> |
| 87 |
</svg> |
| 88 |
<svg class="eye-closed" width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24" style="display:none;"> |
| 89 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"/> |
| 90 |
</svg> |
| 91 |
</button> |
| 92 |
</div> |
| 93 |
</div> |
| 94 |
|
| 95 |
<div class="yatra-form-options"> |
| 96 |
<label class="yatra-checkbox-label"> |
| 97 |
<input type="checkbox" name="rememberme" value="forever"> |
| 98 |
<span><?php esc_html_e('Remember me', 'yatra'); ?></span> |
| 99 |
</label> |
| 100 |
<a href="<?php echo esc_url(wp_lostpassword_url()); ?>" class="yatra-forgot-link"> |
| 101 |
<?php esc_html_e('Forgot password?', 'yatra'); ?> |
| 102 |
</a> |
| 103 |
</div> |
| 104 |
|
| 105 |
<div class="yatra-auth-message" id="yatra-login-message" style="display:none;"></div> |
| 106 |
|
| 107 |
<button type="submit" class="yatra-auth-submit"> |
| 108 |
<span class="btn-text"><?php esc_html_e('Login & Continue', 'yatra'); ?></span> |
| 109 |
<span class="btn-loading" style="display:none;"> |
| 110 |
<svg class="animate-spin" width="18" height="18" fill="none" viewBox="0 0 24 24"> |
| 111 |
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle> |
| 112 |
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path> |
| 113 |
</svg> |
| 114 |
<?php esc_html_e('Logging in...', 'yatra'); ?> |
| 115 |
</span> |
| 116 |
</button> |
| 117 |
</form> |
| 118 |
|
| 119 |
<?php if ($registration_enabled) : ?> |
| 120 |
<div class="yatra-auth-footer"> |
| 121 |
<p><?php esc_html_e("Don't have an account?", 'yatra'); ?> |
| 122 |
<button type="button" class="yatra-switch-tab" data-tab="register"><?php esc_html_e('Register now', 'yatra'); ?></button> |
| 123 |
</p> |
| 124 |
</div> |
| 125 |
<?php endif; ?> |
| 126 |
</div> |
| 127 |
|
| 128 |
<?php if ($registration_enabled) : ?> |
| 129 |
<!-- Registration Form --> |
| 130 |
<div class="yatra-auth-content" id="yatra-auth-register" style="display:none;"> |
| 131 |
<div class="yatra-auth-header"> |
| 132 |
<h2><?php esc_html_e('Create Account', 'yatra'); ?></h2> |
| 133 |
<p><?php esc_html_e('Register to book your trip and manage your bookings.', 'yatra'); ?></p> |
| 134 |
</div> |
| 135 |
|
| 136 |
<form id="yatra-register-form" class="yatra-auth-form" method="post"> |
| 137 |
|
| 138 |
<div class="yatra-form-row"> |
| 139 |
<div class="yatra-form-group"> |
| 140 |
<label for="yatra-reg-first-name"> |
| 141 |
<?php esc_html_e('First Name', 'yatra'); ?> |
| 142 |
<span class="required">*</span> |
| 143 |
</label> |
| 144 |
<input type="text" id="yatra-reg-first-name" name="first_name" required placeholder="<?php esc_attr_e('John', 'yatra'); ?>"> |
| 145 |
</div> |
| 146 |
<div class="yatra-form-group"> |
| 147 |
<label for="yatra-reg-last-name"> |
| 148 |
<?php esc_html_e('Last Name', 'yatra'); ?> |
| 149 |
<span class="required">*</span> |
| 150 |
</label> |
| 151 |
<input type="text" id="yatra-reg-last-name" name="last_name" required placeholder="<?php esc_attr_e('Doe', 'yatra'); ?>"> |
| 152 |
</div> |
| 153 |
</div> |
| 154 |
|
| 155 |
<div class="yatra-form-group"> |
| 156 |
<label for="yatra-reg-email"> |
| 157 |
<?php esc_html_e('Email Address', 'yatra'); ?> |
| 158 |
<span class="required">*</span> |
| 159 |
</label> |
| 160 |
<div class="yatra-input-wrapper"> |
| 161 |
<svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 162 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/> |
| 163 |
</svg> |
| 164 |
<input type="email" id="yatra-reg-email" name="email" required placeholder="<?php esc_attr_e('your@email.com', 'yatra'); ?>"> |
| 165 |
</div> |
| 166 |
</div> |
| 167 |
|
| 168 |
<div class="yatra-form-group"> |
| 169 |
<label for="yatra-reg-phone"> |
| 170 |
<?php esc_html_e('Phone Number', 'yatra'); ?> |
| 171 |
</label> |
| 172 |
<div class="yatra-input-wrapper"> |
| 173 |
<svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 174 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"/> |
| 175 |
</svg> |
| 176 |
<input type="tel" id="yatra-reg-phone" name="phone" placeholder="<?php esc_attr_e('+1 234 567 8900', 'yatra'); ?>"> |
| 177 |
</div> |
| 178 |
</div> |
| 179 |
|
| 180 |
<div class="yatra-form-group"> |
| 181 |
<label for="yatra-reg-password"> |
| 182 |
<?php esc_html_e('Password', 'yatra'); ?> |
| 183 |
<span class="required">*</span> |
| 184 |
</label> |
| 185 |
<div class="yatra-input-wrapper"> |
| 186 |
<svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 187 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"/> |
| 188 |
</svg> |
| 189 |
<input type="password" id="yatra-reg-password" name="password" required minlength="8" placeholder="<?php esc_attr_e('Minimum 8 characters', 'yatra'); ?>"> |
| 190 |
<button type="button" class="yatra-toggle-password" tabindex="-1"> |
| 191 |
<svg class="eye-open" width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 192 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/> |
| 193 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/> |
| 194 |
</svg> |
| 195 |
<svg class="eye-closed" width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24" style="display:none;"> |
| 196 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"/> |
| 197 |
</svg> |
| 198 |
</button> |
| 199 |
</div> |
| 200 |
<div class="yatra-password-strength" id="yatra-password-strength"></div> |
| 201 |
</div> |
| 202 |
|
| 203 |
<div class="yatra-form-group"> |
| 204 |
<label for="yatra-reg-confirm-password"> |
| 205 |
<?php esc_html_e('Confirm Password', 'yatra'); ?> |
| 206 |
<span class="required">*</span> |
| 207 |
</label> |
| 208 |
<div class="yatra-input-wrapper"> |
| 209 |
<svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 210 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"/> |
| 211 |
</svg> |
| 212 |
<input type="password" id="yatra-reg-confirm-password" name="confirm_password" required placeholder="<?php esc_attr_e('Re-enter your password', 'yatra'); ?>"> |
| 213 |
</div> |
| 214 |
</div> |
| 215 |
|
| 216 |
<div class="yatra-form-group"> |
| 217 |
<label class="yatra-checkbox-label"> |
| 218 |
<input type="checkbox" name="terms" required> |
| 219 |
<span> |
| 220 |
<?php |
| 221 |
// Resolve Terms + Privacy URLs from Yatra settings, |
| 222 |
// falling back to WordPress' built-in privacy URL |
| 223 |
// when no Yatra setting is set. Previously both |
| 224 |
// links pointed at the privacy URL — a copy-paste |
| 225 |
// mistake that hid the Terms page from customers. |
| 226 |
$termsPageId = 0; |
| 227 |
$privacyPageId = 0; |
| 228 |
if (class_exists('\\Yatra\\Services\\SettingsService')) { |
| 229 |
$termsPageId = \Yatra\Services\SettingsService::getInt('terms_page_id', 0); |
| 230 |
$privacyPageId = \Yatra\Services\SettingsService::getInt('privacy_policy_page_id', 0); |
| 231 |
} else { |
| 232 |
$termsPageId = (int) get_option('yatra_terms_page_id', 0); |
| 233 |
$privacyPageId = (int) get_option('yatra_privacy_policy_page_id', 0); |
| 234 |
} |
| 235 |
$termsUrl = $termsPageId > 0 ? get_permalink($termsPageId) : ''; |
| 236 |
$privacyUrl = $privacyPageId > 0 ? get_permalink($privacyPageId) : ''; |
| 237 |
if ($privacyUrl === '' && function_exists('get_privacy_policy_url')) { |
| 238 |
$privacyUrl = (string) get_privacy_policy_url(); |
| 239 |
} |
| 240 |
printf( |
| 241 |
/* translators: %1$s: terms link, %2$s: privacy link */ |
| 242 |
esc_html__('I agree to the %1$s and %2$s', 'yatra'), |
| 243 |
'<a href="' . esc_url($termsUrl) . '" target="_blank">' . esc_html__('Terms of Service', 'yatra') . '</a>', |
| 244 |
'<a href="' . esc_url($privacyUrl) . '" target="_blank">' . esc_html__('Privacy Policy', 'yatra') . '</a>' |
| 245 |
); |
| 246 |
?> |
| 247 |
</span> |
| 248 |
</label> |
| 249 |
</div> |
| 250 |
|
| 251 |
<div class="yatra-auth-message" id="yatra-register-message" style="display:none;"></div> |
| 252 |
|
| 253 |
<button type="submit" class="yatra-auth-submit"> |
| 254 |
<span class="btn-text"><?php esc_html_e('Create Account & Continue', 'yatra'); ?></span> |
| 255 |
<span class="btn-loading" style="display:none;"> |
| 256 |
<svg class="animate-spin" width="18" height="18" fill="none" viewBox="0 0 24 24"> |
| 257 |
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle> |
| 258 |
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path> |
| 259 |
</svg> |
| 260 |
<?php esc_html_e('Creating account...', 'yatra'); ?> |
| 261 |
</span> |
| 262 |
</button> |
| 263 |
</form> |
| 264 |
|
| 265 |
<div class="yatra-auth-footer"> |
| 266 |
<p><?php esc_html_e('Already have an account?', 'yatra'); ?> |
| 267 |
<button type="button" class="yatra-switch-tab" data-tab="login"><?php esc_html_e('Login here', 'yatra'); ?></button> |
| 268 |
</p> |
| 269 |
</div> |
| 270 |
</div> |
| 271 |
<?php endif; ?> |
| 272 |
</div> |
| 273 |
|