fix: needs to be uint64

This commit is contained in:
Derrick Hammer 2024-01-17 08:58:58 -05:00
parent bf65e845f3
commit af71f68ea9
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 1 additions and 8 deletions

View File

@ -7,7 +7,6 @@ import (
"github.com/golang-jwt/jwt/v5" "github.com/golang-jwt/jwt/v5"
"go.sia.tech/jape" "go.sia.tech/jape"
"net/http" "net/http"
"strconv"
"strings" "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 { if claim, ok := token.Claims.(jwt.MapClaims); ok && token.Valid {
subject, ok := claim["sub"].(string) userID, ok := claim["sub"].(uint64)
if !ok { if !ok {
http.Error(w, "Invalid User ID", http.StatusBadRequest) http.Error(w, "Invalid User ID", http.StatusBadRequest)
return 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) exists, _ := portal.Accounts().AccountExists(userID)
if !exists { if !exists {