diff --git a/module/member/signin.go b/module/member/signin.go index a1ef7a4..71166a3 100644 --- a/module/member/signin.go +++ b/module/member/signin.go @@ -5,6 +5,7 @@ import ( "crypto/rsa" "fmt" "io/ioutil" + "log" "time" "encoding/json" @@ -78,6 +79,8 @@ func SignIn(ctx *fasthttp.RequestCtx) { /* Create a map to store our claims */ claims := token.Claims.(jwt.MapClaims) + expireTime := time.Now().Add(time.Hour * 24) + /* Set token claims */ claims["iss"] = "overFlow" claims["iat"] = time.Now().Unix() @@ -88,9 +91,15 @@ func SignIn(ctx *fasthttp.RequestCtx) { /* Sign the token with our secret */ tokenString, _ := token.SignedString(signKey) + log.Printf("%s \n", tokenString) + var jwtCookie fasthttp.Cookie jwtCookie.SetKey("AuthToken") jwtCookie.SetValue(tokenString) + // jwtCookie.SetHTTPOnly(true) + jwtCookie.SetSecure(true) + jwtCookie.SetExpire(expireTime) + jwtCookie.SetPath("/") ctx.Response.Header.SetCookie(&jwtCookie) commons.SendRESTResponse(ctx, r)