debug: add detailed logging to password verification
This commit is contained in:
@@ -71,7 +71,9 @@ export function setupCliIPC(mainWindow: BrowserWindow, cliManager: CliProcessMan
|
|||||||
return user
|
return user
|
||||||
})
|
})
|
||||||
ipcMain.handle("users:login", async (_, payload: { id: string; password?: string }) => {
|
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 ?? "")
|
const ok = verifyPassword(payload.id, payload.password ?? "")
|
||||||
|
console.log("[IPC:users:login] verifyPassword result:", ok)
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return { success: false }
|
return { success: false }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,10 +276,19 @@ export function deleteUser(userId: string) {
|
|||||||
export function verifyPassword(userId: string, password: string): boolean {
|
export function verifyPassword(userId: string, password: string): boolean {
|
||||||
const store = readStore()
|
const store = readStore()
|
||||||
const user = store.users.find((u) => u.id === userId)
|
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.isGuest) return true
|
||||||
if (!user.salt || !user.passwordHash) return false
|
if (!user.salt || !user.passwordHash) {
|
||||||
return hashPassword(password, 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) {
|
export function getUserDataRoot(userId: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user