debug: add detailed logging to password verification

This commit is contained in:
Gemini AI
2025-12-29 03:16:39 +04:00
Unverified
parent de2b54b50b
commit 626e00b78d
2 changed files with 14 additions and 3 deletions

View File

@@ -276,10 +276,19 @@ export function deleteUser(userId: string) {
export function verifyPassword(userId: string, password: string): boolean {
const store = readStore()
const user = store.users.find((u) => u.id === userId)
if (!user) return false
if (!user) {
console.log("[verifyPassword] User not found:", userId)
return false
}
if (user.isGuest) return true
if (!user.salt || !user.passwordHash) return false
return hashPassword(password, user.salt) === user.passwordHash
if (!user.salt || !user.passwordHash) {
console.log("[verifyPassword] No salt or hash for user:", userId)
return false
}
const computed = hashPassword(password, user.salt)
const matches = computed === user.passwordHash
console.log("[verifyPassword] userId:", userId, "computed:", computed, "stored:", user.passwordHash, "matches:", matches)
return matches
}
export function getUserDataRoot(userId: string) {