check token expiry

This commit is contained in:
Brad Rydzewski 2015-04-13 19:07:05 -07:00
parent d1d762aa83
commit a40d20dcdb
2 changed files with 9 additions and 2 deletions

View file

@ -60,12 +60,20 @@ func (s *session) GetLogin(r *http.Request) *common.Token {
return nil
}
return &common.Token{
token := &common.Token{
Kind: claims["kind"].(string),
Login: claims["user"].(string),
Label: claims["label"].(string),
Issued: int64(claims["date"].(float64)),
}
if token.Kind != common.TokenSess {
return token
}
if time.Now().UTC().Add(s.expire).Unix() > token.Issued {
return nil
}
return token
}
// getToken is a helper function that extracts the token

View file

@ -1,7 +1,6 @@
package server
import (
"errors"
"time"
"github.com/gin-gonic/gin"