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

@@ -71,7 +71,9 @@ export function setupCliIPC(mainWindow: BrowserWindow, cliManager: CliProcessMan
return user
})
ipcMain.handle("users:login", async (_, payload: { id: string; password?: string }) => {
console.log("[IPC:users:login] Attempting login for:", payload.id, "password length:", payload.password?.length)
const ok = verifyPassword(payload.id, payload.password ?? "")
console.log("[IPC:users:login] verifyPassword result:", ok)
if (!ok) {
return { success: false }
}

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) {