Spaces:
Sleeping
Sleeping
Update templates/change_password.html
Browse files- templates/change_password.html +44 -35
templates/change_password.html
CHANGED
|
@@ -21,40 +21,11 @@
|
|
| 21 |
padding: 2rem;
|
| 22 |
}
|
| 23 |
.password-header { text-align: center; margin-bottom: 2rem; }
|
| 24 |
-
.password-icon {
|
| 25 |
-
width: 70px;
|
| 26 |
-
height: 70px;
|
| 27 |
-
background: linear-gradient(135deg, #f59e0b, #d97706);
|
| 28 |
-
border-radius: 50%;
|
| 29 |
-
display: flex;
|
| 30 |
-
align-items: center;
|
| 31 |
-
justify-content: center;
|
| 32 |
-
margin: 0 auto 1rem;
|
| 33 |
-
}
|
| 34 |
.password-icon i { font-size: 2rem; color: white; }
|
| 35 |
-
.btn-change {
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
background: linear-gradient(135deg, #3b82f6, #2563eb);
|
| 39 |
-
border: none;
|
| 40 |
-
border-radius: 0.75rem;
|
| 41 |
-
color: white;
|
| 42 |
-
font-weight: 600;
|
| 43 |
-
cursor: pointer;
|
| 44 |
-
margin-bottom: 1rem;
|
| 45 |
-
}
|
| 46 |
-
.btn-back {
|
| 47 |
-
display: inline-flex;
|
| 48 |
-
align-items: center;
|
| 49 |
-
gap: 0.5rem;
|
| 50 |
-
background: #334155;
|
| 51 |
-
color: white;
|
| 52 |
-
padding: 0.75rem 1.5rem;
|
| 53 |
-
border-radius: 0.75rem;
|
| 54 |
-
text-decoration: none;
|
| 55 |
-
width: 100%;
|
| 56 |
-
justify-content: center;
|
| 57 |
-
}
|
| 58 |
</style>
|
| 59 |
{% endblock %}
|
| 60 |
|
|
@@ -67,7 +38,7 @@
|
|
| 67 |
<p>Masukkan password lama dan password baru Anda</p>
|
| 68 |
</div>
|
| 69 |
|
| 70 |
-
<form
|
| 71 |
<div class="form-group"><label>Password Lama</label><input type="password" id="oldPassword" placeholder="Masukkan password lama" required></div>
|
| 72 |
<div class="form-group"><label>Password Baru</label><input type="password" id="newPassword" placeholder="Minimal 6 karakter" required></div>
|
| 73 |
<div class="form-group"><label>Konfirmasi Password Baru</label><input type="password" id="confirmPassword" placeholder="Ulangi password baru" required></div>
|
|
@@ -76,5 +47,43 @@
|
|
| 76 |
</form>
|
| 77 |
</div>
|
| 78 |
</div>
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
{% endblock %}
|
|
|
|
| 21 |
padding: 2rem;
|
| 22 |
}
|
| 23 |
.password-header { text-align: center; margin-bottom: 2rem; }
|
| 24 |
+
.password-icon { width: 70px; height: 70px; background: linear-gradient(135deg, #f59e0b, #d97706); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
.password-icon i { font-size: 2rem; color: white; }
|
| 26 |
+
.btn-change { width: 100%; padding: 0.875rem; background: linear-gradient(135deg, #3b82f6, #2563eb); border: none; border-radius: 0.75rem; color: white; font-weight: 600; cursor: pointer; margin-bottom: 1rem; }
|
| 27 |
+
.btn-change:hover { transform: translateY(-2px); box-shadow: 0 10px 20px -5px #3b82f6; }
|
| 28 |
+
.btn-back { display: inline-flex; align-items: center; gap: 0.5rem; background: #334155; color: white; padding: 0.75rem 1.5rem; border-radius: 0.75rem; text-decoration: none; width: 100%; justify-content: center; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
</style>
|
| 30 |
{% endblock %}
|
| 31 |
|
|
|
|
| 38 |
<p>Masukkan password lama dan password baru Anda</p>
|
| 39 |
</div>
|
| 40 |
|
| 41 |
+
<form id="changePasswordForm">
|
| 42 |
<div class="form-group"><label>Password Lama</label><input type="password" id="oldPassword" placeholder="Masukkan password lama" required></div>
|
| 43 |
<div class="form-group"><label>Password Baru</label><input type="password" id="newPassword" placeholder="Minimal 6 karakter" required></div>
|
| 44 |
<div class="form-group"><label>Konfirmasi Password Baru</label><input type="password" id="confirmPassword" placeholder="Ulangi password baru" required></div>
|
|
|
|
| 47 |
</form>
|
| 48 |
</div>
|
| 49 |
</div>
|
| 50 |
+
|
| 51 |
+
<script>
|
| 52 |
+
document.getElementById('changePasswordForm').addEventListener('submit', async function(e) {
|
| 53 |
+
e.preventDefault();
|
| 54 |
+
|
| 55 |
+
const oldPassword = document.getElementById('oldPassword').value;
|
| 56 |
+
const newPassword = document.getElementById('newPassword').value;
|
| 57 |
+
const confirmPassword = document.getElementById('confirmPassword').value;
|
| 58 |
+
|
| 59 |
+
if (newPassword !== confirmPassword) { alert('Password baru tidak cocok!'); return; }
|
| 60 |
+
if (newPassword.length < 6) { alert('Password minimal 6 karakter'); return; }
|
| 61 |
+
|
| 62 |
+
const btn = e.target.querySelector('button');
|
| 63 |
+
btn.disabled = true;
|
| 64 |
+
btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Memproses...';
|
| 65 |
+
|
| 66 |
+
try {
|
| 67 |
+
const response = await fetch('/api/auth/change-password', {
|
| 68 |
+
method: 'POST',
|
| 69 |
+
headers: { 'Content-Type': 'application/json' },
|
| 70 |
+
body: JSON.stringify({ old_password: oldPassword, new_password: newPassword })
|
| 71 |
+
});
|
| 72 |
+
const result = await response.json();
|
| 73 |
+
|
| 74 |
+
if (result.success) {
|
| 75 |
+
alert('Password berhasil diubah!');
|
| 76 |
+
window.location.href = '/profile';
|
| 77 |
+
} else {
|
| 78 |
+
alert('Error: ' + (result.error || 'Gagal mengubah password'));
|
| 79 |
+
btn.disabled = false;
|
| 80 |
+
btn.innerHTML = '<i class="fas fa-save"></i> Simpan Password';
|
| 81 |
+
}
|
| 82 |
+
} catch (error) {
|
| 83 |
+
alert('Terjadi kesalahan: ' + error.message);
|
| 84 |
+
btn.disabled = false;
|
| 85 |
+
btn.innerHTML = '<i class="fas fa-save"></i> Simpan Password';
|
| 86 |
+
}
|
| 87 |
+
});
|
| 88 |
+
</script>
|
| 89 |
{% endblock %}
|