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:
soup 2026-01-17 22:28:13 -05:00
parent 5b472de209
commit 523831cb8d
Signed by: soup
SSH key fingerprint: SHA256:GYxje8eQkJ6HZKzVWDdyOUF1TyDiprruGhE0Ym8qYDY
6 changed files with 178 additions and 6 deletions

View file

@ -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");