add logout

This commit is contained in:
kandrusyak
2023-07-28 01:48:49 +03:00
parent e55aea13b4
commit c90fa01388
2 changed files with 13 additions and 9 deletions

View File

@@ -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)
}