Skip to content

Commit f6e352b

Browse files
committed
log a message even if the error isn't a protocol.Error
1 parent d6692e1 commit f6e352b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

user.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -378,14 +378,6 @@ func (u *DynamoUser) FinishLogin(r *http.Request) (*webauthn.Credential, error)
378378
return credential, nil
379379
}
380380

381-
// logProtocolError logs a message if the given error is an Error from go-webauthn/webauthn/protocol
382-
func logProtocolError(msg string, err error) {
383-
var protocolError *protocol.Error
384-
if errors.As(err, &protocolError) {
385-
log.Printf("%s, ProtocolError: %s, DevInfo: %s", msg, protocolError.Details, protocolError.DevInfo)
386-
}
387-
}
388-
389381
// User ID according to the Relying Party
390382
func (u *DynamoUser) WebAuthnID() []byte {
391383
return []byte(u.ID)
@@ -489,3 +481,13 @@ func hashAndEncodeKeyHandle(id []byte) string {
489481
hash := sha256.Sum256(id)
490482
return base64.RawURLEncoding.EncodeToString(hash[:])
491483
}
484+
485+
// logProtocolError logs a detailed message if the given error is an Error from go-webauthn/webauthn/protocol
486+
func logProtocolError(msg string, err error) {
487+
var protocolError *protocol.Error
488+
if errors.As(err, &protocolError) {
489+
log.Printf("%s, ProtocolError: %s, DevInfo: %s", msg, protocolError.Details, protocolError.DevInfo)
490+
} else {
491+
log.Printf("%s, Error: %s", msg, err)
492+
}
493+
}

0 commit comments

Comments
 (0)