From f6e352b1938275cb1d0c038a162b46f20f5f78b9 Mon Sep 17 00:00:00 2001 From: briskt <3172830+briskt@users.noreply.github.com> Date: Tue, 12 Nov 2024 16:16:17 +0800 Subject: [PATCH] log a message even if the error isn't a protocol.Error --- user.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/user.go b/user.go index 5a0df13..b2afa1e 100644 --- a/user.go +++ b/user.go @@ -378,14 +378,6 @@ func (u *DynamoUser) FinishLogin(r *http.Request) (*webauthn.Credential, error) return credential, nil } -// logProtocolError logs a message if the given error is an Error from go-webauthn/webauthn/protocol -func logProtocolError(msg string, err error) { - var protocolError *protocol.Error - if errors.As(err, &protocolError) { - log.Printf("%s, ProtocolError: %s, DevInfo: %s", msg, protocolError.Details, protocolError.DevInfo) - } -} - // User ID according to the Relying Party func (u *DynamoUser) WebAuthnID() []byte { return []byte(u.ID) @@ -489,3 +481,13 @@ func hashAndEncodeKeyHandle(id []byte) string { hash := sha256.Sum256(id) return base64.RawURLEncoding.EncodeToString(hash[:]) } + +// logProtocolError logs a detailed message if the given error is an Error from go-webauthn/webauthn/protocol +func logProtocolError(msg string, err error) { + var protocolError *protocol.Error + if errors.As(err, &protocolError) { + log.Printf("%s, ProtocolError: %s, DevInfo: %s", msg, protocolError.Details, protocolError.DevInfo) + } else { + log.Printf("%s, Error: %s", msg, err) + } +}