| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) |
| 3 |
exit; // Exit if accessed directly |
| 4 |
|
| 5 |
// Vérifier si l'utilisateur a déjà un token JWT |
| 6 |
$jwt_token = get_option('aibui_jwt_token', ''); |
| 7 |
|
| 8 |
// Vérifier le nonce pour les paramètres GET |
| 9 |
$nonce = isset($_GET['_wpnonce']) ? sanitize_text_field(wp_unslash($_GET['_wpnonce'])) : ''; |
| 10 |
if (!empty($_GET['token']) || !empty($_GET['email'])) { |
| 11 |
if (!wp_verify_nonce($nonce, 'aibui_reset_password_link')) { |
| 12 |
wp_die('Security check failed'); |
| 13 |
} |
| 14 |
} |
| 15 |
|
| 16 |
$reset_token = isset($_GET['token']) ? sanitize_text_field(wp_unslash($_GET['token'])) : ''; |
| 17 |
$email = isset($_GET['email']) ? sanitize_email(wp_unslash($_GET['email'])) : ''; |
| 18 |
|
| 19 |
// Déterminer quelle vue afficher |
| 20 |
$show_email_form = empty($reset_token); |
| 21 |
$show_password_form = !empty($reset_token) && !empty($email); |
| 22 |
?> |
| 23 |
|
| 24 |
<div class="ai-reset-container ai-fade-in"> |
| 25 |
<?php if ($show_email_form): ?> |
| 26 |
<!-- Formulaire pour entrer l'email --> |
| 27 |
<div class="ai-reset-header"> |
| 28 |
<h2>Reset Password</h2> |
| 29 |
<p>Enter your email address to receive a password reset link</p> |
| 30 |
</div> |
| 31 |
|
| 32 |
<form class="ai-reset-form" id="email-form"> |
| 33 |
<?php wp_nonce_field('aibui_reset_email', 'aibui_nonce'); ?> |
| 34 |
<div class="ai-form-group"> |
| 35 |
<label for="reset-email">Email Address</label> |
| 36 |
<input type="email" id="reset-email" name="email" required> |
| 37 |
</div> |
| 38 |
|
| 39 |
<button type="submit" class="ai-submit-btn" id="send-reset-btn"> |
| 40 |
<span class="ai-loading" style="display: none;"></span> |
| 41 |
Send Reset Link |
| 42 |
</button> |
| 43 |
</form> |
| 44 |
|
| 45 |
<div class="ai-back-to-signin"> |
| 46 |
<a href="<?php echo esc_url(admin_url('admin.php?page=aibui-assistant')); ?>" class="ai-link"> |
| 47 |
← Back to Sign In |
| 48 |
</a> |
| 49 |
</div> |
| 50 |
|
| 51 |
<?php elseif ($show_password_form): ?> |
| 52 |
<!-- Formulaire pour le nouveau mot de passe --> |
| 53 |
<div class="ai-reset-header"> |
| 54 |
<h2>Set New Password</h2> |
| 55 |
<p>Enter your new password below</p> |
| 56 |
</div> |
| 57 |
|
| 58 |
<form class="ai-reset-form" id="password-form"> |
| 59 |
<?php wp_nonce_field('aibui_reset_password', 'aibui_nonce'); ?> |
| 60 |
<input type="hidden" id="reset-token" name="token" value="<?php echo esc_attr($reset_token); ?>"> |
| 61 |
<input type="hidden" id="reset-email" name="email" value="<?php echo esc_attr($email); ?>"> |
| 62 |
|
| 63 |
<div class="ai-form-group"> |
| 64 |
<label for="new-password">New Password</label> |
| 65 |
<input type="password" id="new-password" name="password" required minlength="8"> |
| 66 |
</div> |
| 67 |
|
| 68 |
<div class="ai-form-group"> |
| 69 |
<label for="confirm-new-password">Confirm New Password</label> |
| 70 |
<input type="password" id="confirm-new-password" name="confirm_password" required minlength="8"> |
| 71 |
</div> |
| 72 |
|
| 73 |
<button type="submit" class="ai-submit-btn" id="reset-password-btn"> |
| 74 |
<span class="ai-loading" style="display: none;"></span> |
| 75 |
Reset Password |
| 76 |
</button> |
| 77 |
</form> |
| 78 |
|
| 79 |
<div class="ai-back-to-signin"> |
| 80 |
<a href="<?php echo esc_url(admin_url('admin.php?page=aibui-assistant')); ?>" class="ai-link"> |
| 81 |
← Back to Sign In |
| 82 |
</a> |
| 83 |
</div> |
| 84 |
<?php endif; ?> |
| 85 |
|
| 86 |
<div id="message-container"></div> |
| 87 |
</div> |