debug: add detailed logging to password verification
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user