From 7c8698da865155b9bf827d025a6159df7503f380 Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Tue, 27 Dec 2016 00:28:05 +0100 Subject: [PATCH] Add ID to token --- jwt/login.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/jwt/login.go b/jwt/login.go index ffd4929..cb1e557 100644 --- a/jwt/login.go +++ b/jwt/login.go @@ -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 +}