mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-04-04 20:17:15 +08:00
Use TokenSize const in api common.go
This commit is contained in:
parent
39199dc1b1
commit
25abf4914b
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/pagefaultgames/pokerogue-server/api/account"
|
||||||
"github.com/pagefaultgames/pokerogue-server/api/daily"
|
"github.com/pagefaultgames/pokerogue-server/api/daily"
|
||||||
"github.com/pagefaultgames/pokerogue-server/db"
|
"github.com/pagefaultgames/pokerogue-server/db"
|
||||||
)
|
)
|
||||||
@ -24,8 +25,8 @@ func getUsernameFromRequest(r *http.Request) (string, error) {
|
|||||||
return "", fmt.Errorf("failed to decode token: %s", err)
|
return "", fmt.Errorf("failed to decode token: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(token) != 32 {
|
if len(token) != account.TokenSize {
|
||||||
return "", fmt.Errorf("invalid token length: got %d, expected 32", len(token))
|
return "", fmt.Errorf("invalid token length: got %d, expected %d", len(token), account.TokenSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
username, err := db.FetchUsernameFromToken(token)
|
username, err := db.FetchUsernameFromToken(token)
|
||||||
@ -46,8 +47,8 @@ func getUUIDFromRequest(r *http.Request) ([]byte, error) {
|
|||||||
return nil, fmt.Errorf("failed to decode token: %s", err)
|
return nil, fmt.Errorf("failed to decode token: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(token) != 32 {
|
if len(token) != account.TokenSize {
|
||||||
return nil, fmt.Errorf("invalid token length: got %d, expected 32", len(token))
|
return nil, fmt.Errorf("invalid token length: got %d, expected %d", len(token), account.TokenSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
uuid, err := db.FetchUUIDFromToken(token)
|
uuid, err := db.FetchUUIDFromToken(token)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user