fix jwt auth

This commit is contained in:
Kochan 2018-11-26 21:09:42 +01:00
parent 9b27282ee3
commit 1b261b983c
5 changed files with 23 additions and 22 deletions

View file

@ -6,7 +6,7 @@ import (
"time"
"github.com/dhax/go-base/auth/jwt"
"github.com/go-chi/jwtauth"
jwtgo "github.com/dgrijalva/jwt-go"
validation "github.com/go-ozzo/ozzo-validation"
"github.com/go-ozzo/ozzo-validation/is"
"github.com/go-pg/pg/orm"
@ -66,8 +66,8 @@ func (a *Account) CanLogin() bool {
}
// Claims returns the account's claims to be signed
func (a *Account) Claims() jwtauth.Claims {
return jwtauth.Claims{
func (a *Account) Claims() jwtgo.MapClaims {
return jwtgo.MapClaims{
"id": a.ID,
"sub": a.Name,
"roles": a.Roles,

View file

@ -187,7 +187,7 @@ func (rs *Resource) token(w http.ResponseWriter, r *http.Request) {
browser, _ := ua.Browser()
token := &jwt.Token{
Token: uuid.NewV4().String(),
Token: uuid.Must(uuid.NewV4()).String(),
Expiry: time.Now().Add(rs.TokenAuth.JwtRefreshExpiry),
UpdatedAt: time.Now(),
AccountID: acc.ID,
@ -247,7 +247,7 @@ func (rs *Resource) refresh(w http.ResponseWriter, r *http.Request) {
return
}
token.Token = uuid.NewV4().String()
token.Token = uuid.Must(uuid.NewV4()).String()
token.Expiry = time.Now().Add(rs.TokenAuth.JwtRefreshExpiry)
token.UpdatedAt = time.Now()