From b4355ee91355a0a3ce69f8b815f0f52cd31fa494 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Tue, 9 Jan 2024 21:30:14 +1100 Subject: [PATCH] more logging --- models/key.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/models/key.go b/models/key.go index 475b729..50be628 100644 --- a/models/key.go +++ b/models/key.go @@ -46,14 +46,17 @@ func storeKeyHash(plaintext string, filePath string) error { func compareHashWithPlaintext(plaintext string, filePath string) (bool, error) { hashBytes, err := os.ReadFile(filePath) if err != nil { + log.Printf("compareHashWithPlaintext error reading hashfile : '%s'\n", err) return false, err } err = bcrypt.CompareHashAndPassword(hashBytes, []byte(plaintext)) if err != nil { if err == bcrypt.ErrMismatchedHashAndPassword { + log.Printf("compareHashWithPlaintext provided key is incorrect") return false, nil // Passwords don't match } + log.Printf("compareHashWithPlaintext error comparing provided key : '%s'\n", err) return false, err // Other error occurred } @@ -71,6 +74,7 @@ func ReceiveKey(key string) error { filePath, _ := getHashFilePath() if filePath != "" { + log.Printf("ReceiveKey detected hash file at '%s'\n", filePath) // File already exists, compare received key with hash in file compare, err := compareHashWithPlaintext(key, filePath) if err != nil {