fix: needs to be uint64
This commit is contained in:
parent
bf65e845f3
commit
af71f68ea9
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue