From af71f68ea9f1cb09419ae30569be718adaabcded Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 17 Jan 2024 08:58:58 -0500 Subject: [PATCH] fix: needs to be uint64 --- api/s5/middleware.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/api/s5/middleware.go b/api/s5/middleware.go index ab82793..391dbb4 100644 --- a/api/s5/middleware.go +++ b/api/s5/middleware.go @@ -7,7 +7,6 @@ import ( "github.com/golang-jwt/jwt/v5" "go.sia.tech/jape" "net/http" - "strconv" "strings" ) @@ -42,18 +41,12 @@ func AuthMiddleware(handler jape.Handler, portal interfaces.Portal) jape.Handler } if claim, ok := token.Claims.(jwt.MapClaims); ok && token.Valid { - subject, ok := claim["sub"].(string) + userID, ok := claim["sub"].(uint64) if !ok { http.Error(w, "Invalid User ID", http.StatusBadRequest) return } - userID, err := strconv.ParseUint(subject, 10, 64) - if err != nil { - http.Error(w, "Invalid User ID", http.StatusBadRequest) - return - } - exists, _ := portal.Accounts().AccountExists(userID) if !exists {