X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=api%2Fauth_jwt.go;h=27cc3b0797d8f272cbcc35c968d52e45ea30c49a;hb=e0ab9e8caa9237d3e15193fcb0ca74954afc66be;hp=f713f4e9be9ef710da6f14e881a6db5f85a67c24;hpb=7a9e5112eaaea58d55f181d3e5296e4ff839921c;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FFront.git diff --git a/api/auth_jwt.go b/api/auth_jwt.go index f713f4e..27cc3b0 100644 --- a/api/auth_jwt.go +++ b/api/auth_jwt.go @@ -5,7 +5,7 @@ import ( "strings" "time" - "immae.eu/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front/db" + "git.immae.eu/Cryptoportfolio/Front.git/db" "github.com/dgrijalva/jwt-go" "github.com/gin-gonic/gin" @@ -20,10 +20,6 @@ type JwtClaims struct { jwt.StandardClaims } -func SetJwtSecretKey(secret string) { - JWT_SECRET = []byte(secret) -} - func VerifyJwtToken(token string) (JwtClaims, error) { if len(JWT_SECRET) == 0 { return JwtClaims{}, fmt.Errorf("not initialized jwt secret") @@ -61,7 +57,7 @@ func CreateJwtToken(userId int64) (string, error) { false, userId, jwt.StandardClaims{ - ExpiresAt: time.Now().Add(time.Hour * 24).Unix(), + ExpiresAt: time.Now().Add(time.Hour * 24 * 7).Unix(), }, } @@ -96,6 +92,7 @@ func JwtAuth(c *gin.Context) *Error { c.Set("user", *user) c.Set("claims", claims) + SetContextLogField(c, "user_id", user.Id) return nil }