Add password change functionality
- Add POST /api/auth/password API endpoint
- Requires authentication and current password verification
- Invalidates all other sessions after password change
- Keeps current session active
- Add window.changePassword() console function
- Matches existing login flow pattern
- Usage: changePassword("current", "new")
- Add 'lookbook set-password' CLI command
- Interactive password reset (no current password required)
- Useful for recovery scenarios
- Invalidates all sessions
- Add session.QDeleteAllExcept() and session.QDeleteAll()
- Support for invalidating sessions after password change
This commit is contained in:
parent
5b472de209
commit
523831cb8d
6 changed files with 178 additions and 6 deletions
|
|
@ -36,6 +36,28 @@ window.logout = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
window.changePassword = async (currentPassword, newPassword) => {
|
||||
if (!currentPassword || !newPassword) {
|
||||
console.error('Usage: changePassword("current-password", "new-password")');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const res = await fetch("/api/auth/password", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ currentPassword, newPassword }),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (res.ok) {
|
||||
console.log("Password changed successfully!");
|
||||
} else {
|
||||
console.error(data.error || "Failed to change password");
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Password change error:", err);
|
||||
}
|
||||
};
|
||||
|
||||
// Modal functions
|
||||
function showAddModal() {
|
||||
document.getElementById("add-modal").classList.add("active");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue