| 1 | <!DOCTYPE html>
|
|---|
| 2 | <html lang="en">
|
|---|
| 3 | <head>
|
|---|
| 4 | <meta charset="UTF-8">
|
|---|
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|---|
| 6 | <title>Change Password - Handcraft Marketplace</title>
|
|---|
| 7 | <link rel="stylesheet" href="style.css">
|
|---|
| 8 | </head>
|
|---|
| 9 | <body>
|
|---|
| 10 | <header>
|
|---|
| 11 | <div class="logo-container">
|
|---|
| 12 | <img src="../images/administrative/logo.jpg" alt="Handcraft Marketplace Logo" onerror="this.style.display='none'">
|
|---|
| 13 | <h1>🎨 Handcraft Marketplace</h1>
|
|---|
| 14 | </div>
|
|---|
| 15 | <nav>
|
|---|
| 16 | <ul>
|
|---|
| 17 | <li><a href="index.html">Home</a></li>
|
|---|
| 18 | <li><a href="products.html">Products</a></li>
|
|---|
| 19 | <li><a href="login.html">Login</a></li>
|
|---|
| 20 | </ul>
|
|---|
| 21 | </nav>
|
|---|
| 22 | </header>
|
|---|
| 23 |
|
|---|
| 24 | <main>
|
|---|
| 25 | <div class="form-container">
|
|---|
| 26 | <h2>Change Password</h2>
|
|---|
| 27 | <p class="form-subtitle" id="password-message">Please set a new password</p>
|
|---|
| 28 |
|
|---|
| 29 | <form id="change-password-form" class="form">
|
|---|
| 30 | <div class="form-group">
|
|---|
| 31 | <label for="current-password">Current Password</label>
|
|---|
| 32 | <input type="password" id="current-password" name="current-password" required>
|
|---|
| 33 | </div>
|
|---|
| 34 |
|
|---|
| 35 | <div class="form-group">
|
|---|
| 36 | <label for="new-password">New Password</label>
|
|---|
| 37 | <input type="password" id="new-password" name="new-password" required>
|
|---|
| 38 | <small class="password-hint">At least 8 characters with uppercase, lowercase, number, and special character</small>
|
|---|
| 39 | </div>
|
|---|
| 40 |
|
|---|
| 41 | <div class="form-group">
|
|---|
| 42 | <label for="confirm-password">Confirm New Password</label>
|
|---|
| 43 | <input type="password" id="confirm-password" name="confirm-password" required>
|
|---|
| 44 | </div>
|
|---|
| 45 |
|
|---|
| 46 | <div class="form-group">
|
|---|
| 47 | <button type="submit" class="btn-primary btn-full">Change Password</button>
|
|---|
| 48 | </div>
|
|---|
| 49 | </form>
|
|---|
| 50 | </div>
|
|---|
| 51 | </main>
|
|---|
| 52 |
|
|---|
| 53 | <footer>
|
|---|
| 54 | <div class="footer-content">
|
|---|
| 55 | <div class="footer-section">
|
|---|
| 56 | <h3>Handcraft Marketplace</h3>
|
|---|
| 57 | <p>Connecting artisans with buyers worldwide</p>
|
|---|
| 58 | </div>
|
|---|
| 59 | <div class="footer-section">
|
|---|
| 60 | <h3>Quick Links</h3>
|
|---|
| 61 | <ul>
|
|---|
| 62 | <li><a href="index.html">Home</a></li>
|
|---|
| 63 | <li><a href="products.html">Products</a></li>
|
|---|
| 64 | </ul>
|
|---|
| 65 | </div>
|
|---|
| 66 | </div>
|
|---|
| 67 | <div class="footer-bottom">
|
|---|
| 68 | <p>© 2025 Handcraft Marketplace. All rights reserved.</p>
|
|---|
| 69 | </div>
|
|---|
| 70 | </footer>
|
|---|
| 71 |
|
|---|
| 72 | <script src="script.js"></script>
|
|---|
| 73 | <script>
|
|---|
| 74 | document.addEventListener('DOMContentLoaded', () => {
|
|---|
| 75 | const urlParams = new URLSearchParams(window.location.search);
|
|---|
| 76 | const isForced = urlParams.get('forced') === 'true';
|
|---|
| 77 |
|
|---|
| 78 | if (isForced) {
|
|---|
| 79 | document.getElementById('password-message').textContent =
|
|---|
| 80 | 'You must change your password before continuing.';
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | const form = document.getElementById('change-password-form');
|
|---|
| 84 | form.addEventListener('submit', async (e) => {
|
|---|
| 85 | e.preventDefault();
|
|---|
| 86 |
|
|---|
| 87 | const newPassword = document.getElementById('new-password').value;
|
|---|
| 88 | const confirmPassword = document.getElementById('confirm-password').value;
|
|---|
| 89 |
|
|---|
| 90 | if (newPassword !== confirmPassword) {
|
|---|
| 91 | alert('New passwords do not match');
|
|---|
| 92 | return;
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | const formData = {
|
|---|
| 96 | currentPassword: document.getElementById('current-password').value,
|
|---|
| 97 | newPassword: newPassword,
|
|---|
| 98 | confirmPassword: confirmPassword
|
|---|
| 99 | };
|
|---|
| 100 |
|
|---|
| 101 | try {
|
|---|
| 102 | const response = await fetch('/api/force-change-password', {
|
|---|
| 103 | method: 'POST',
|
|---|
| 104 | headers: { 'Content-Type': 'application/json' },
|
|---|
| 105 | body: JSON.stringify(formData)
|
|---|
| 106 | });
|
|---|
| 107 |
|
|---|
| 108 | const data = await response.json();
|
|---|
| 109 |
|
|---|
| 110 | if (data.success) {
|
|---|
| 111 | alert('Password changed successfully!');
|
|---|
| 112 | window.location.href = data.redirectTo || 'dashboard.html';
|
|---|
| 113 | } else {
|
|---|
| 114 | alert(data.message || 'Failed to change password');
|
|---|
| 115 | }
|
|---|
| 116 | } catch (error) {
|
|---|
| 117 | console.error('Password change error:', error);
|
|---|
| 118 | alert('An error occurred');
|
|---|
| 119 | }
|
|---|
| 120 | });
|
|---|
| 121 | });
|
|---|
| 122 | </script>
|
|---|
| 123 | </body>
|
|---|
| 124 | </html> |
|---|