From c90fa013885d533229e871d4ac037561de0be02f Mon Sep 17 00:00:00 2001 From: kandrusyak Date: Fri, 28 Jul 2023 01:48:49 +0300 Subject: [PATCH] add logout --- main.go | 2 +- services/users/users.go | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index 0d9bfb8..5148479 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,7 @@ import ( "astra-api-gateway/handler" "astra-api-gateway/mw" "astra-api-gateway/services/events" - medical_information "astra-api-gateway/services/medical-information" + "astra-api-gateway/services/medical-information" "astra-api-gateway/services/personal-information" "astra-api-gateway/services/store" "astra-api-gateway/services/users" diff --git a/services/users/users.go b/services/users/users.go index dc110d2..e2b4ac8 100644 --- a/services/users/users.go +++ b/services/users/users.go @@ -43,10 +43,12 @@ func Login(c echo.Context) (err error) { } c.SetCookie(&http.Cookie{ - Name: "accessToken", - Value: _token, - Path: "/", - Expires: time.Now().Add(24 * time.Hour), + Name: "accessToken", + Value: _token, + Path: "/", + Expires: time.Now().Add(24 * time.Hour), + Secure: true, + SameSite: 4, }) return c.JSON(http.StatusOK, u) @@ -54,10 +56,12 @@ func Login(c echo.Context) (err error) { func Logout(c echo.Context) error { c.SetCookie(&http.Cookie{ - Name: "accessToken", - Value: "", - Path: "/", - Expires: time.Unix(0, 0), + Name: "accessToken", + Value: "", + Path: "/", + Expires: time.Unix(0, 0), + Secure: true, + SameSite: 4, }) return c.NoContent(http.StatusOK) }