Use uuid.UUID everywhere and have postgres generate ids

This commit is contained in:
2021-11-29 21:49:37 +00:00
parent 5e8a98872f
commit 85ef7557c1
19 changed files with 199 additions and 93 deletions

View File

@ -7,6 +7,7 @@ import (
"git.javil.eu/jacob1123/budgeteer"
"git.javil.eu/jacob1123/budgeteer/postgres"
"github.com/dgrijalva/jwt-go"
"github.com/google/uuid"
)
// TokenVerifier verifies Tokens
@ -18,7 +19,7 @@ type Token struct {
username string
name string
expiry float64
id string
id uuid.UUID
}
const (
@ -65,7 +66,7 @@ func (tv *TokenVerifier) VerifyToken(tokenString string) (budgeteer.Token, error
username: claims["usr"].(string),
name: claims["name"].(string),
expiry: claims["exp"].(float64),
id: claims["id"].(string),
id: uuid.MustParse(claims["id"].(string)),
}
return tkn, nil
}
@ -99,6 +100,6 @@ func (t *Token) GetExpiry() float64 {
return t.expiry
}
func (t *Token) GetID() string {
func (t *Token) GetID() uuid.UUID {
return t.id
}