Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zkokelj committed Apr 3, 2024
1 parent 4affa8a commit c9c0792
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/walletextension/httpapi/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ func getUserID(conn UserConn) ([]byte, error) {
// try getting userID (`token`) from query parameters and return it if successful
userID, err := getQueryParameter(conn.ReadRequestParams(), common.EncryptedTokenQueryParameter)
if err == nil {
if len(userID) != common.MessageUserIDLenWithPrefix {
return nil, fmt.Errorf(fmt.Sprintf("wrong length of userID from URL. Got: %d, Expected: %d", len(userID), common.MessageUserIDLenWithPrefix))
if len(userID) == common.MessageUserIDLenWithPrefix {
return hexutils.HexToBytes(userID[2:]), nil
} else if len(userID) == common.MessageUserIDLen {
return hexutils.HexToBytes(userID), nil
}
return hexutils.HexToBytes(userID[2:]), err

return nil, fmt.Errorf(fmt.Sprintf("wrong length of userID from URL. Got: %d, Expected: %d od %d", len(userID), common.MessageUserIDLenWithPrefix, common.MessageUserIDLen))
}

return nil, fmt.Errorf("missing token field")
Expand Down

0 comments on commit c9c0792

Please sign in to comment.