add logout

This commit is contained in:
kandrusyak
2023-07-28 01:39:20 +03:00
parent 16c9767420
commit e55aea13b4
2 changed files with 15 additions and 7 deletions

View File

@@ -43,18 +43,25 @@ func Login(c echo.Context) (err error) {
}
c.SetCookie(&http.Cookie{
Name: "accessToken",
Value: _token,
Path: "/",
MaxAge: 31536000,
Expires: time.Now().Add(24 * time.Hour),
Secure: true,
SameSite: 4,
Name: "accessToken",
Value: _token,
Path: "/",
Expires: time.Now().Add(24 * time.Hour),
})
return c.JSON(http.StatusOK, u)
}
func Logout(c echo.Context) error {
c.SetCookie(&http.Cookie{
Name: "accessToken",
Value: "",
Path: "/",
Expires: time.Unix(0, 0),
})
return c.NoContent(http.StatusOK)
}
func GetCurrentUser(c echo.Context) error {
data, err, _ := api.GetRequest(config.Env.MSHosts.UsersHost+"/me", c.Request().Header)