]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git/blobdiff - api/auth_jwt.go
Context log fields.
[perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git] / api / auth_jwt.go
index 5ce159369a89180650aa706bf65db1d3290a5d16..27cc3b0797d8f272cbcc35c968d52e45ea30c49a 100644 (file)
@@ -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")
@@ -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
 }