Add ID to token
This commit is contained in:
parent
f36fe1b1c0
commit
7c8698da86
@ -17,6 +17,7 @@ type Token struct {
|
||||
username string
|
||||
name string
|
||||
expiry float64
|
||||
id string
|
||||
}
|
||||
|
||||
const (
|
||||
@ -30,6 +31,7 @@ func (tv *TokenVerifier) CreateToken(user *budgeteer.User) (string, error) {
|
||||
"usr": user.Email,
|
||||
"name": user.Name,
|
||||
"exp": time.Now().Add(time.Hour * expiration).Unix(),
|
||||
"id": user.ID,
|
||||
})
|
||||
|
||||
// Generate encoded token and send it as response.
|
||||
@ -62,6 +64,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),
|
||||
}
|
||||
return tkn, nil
|
||||
}
|
||||
@ -94,3 +97,7 @@ func (t *Token) GetUsername() string {
|
||||
func (t *Token) GetExpiry() float64 {
|
||||
return t.expiry
|
||||
}
|
||||
|
||||
func (t *Token) GetID() string {
|
||||
return t.id
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user