first commit

This commit is contained in:
2024-10-02 00:57:17 +08:00
commit 6773f86bc5
312 changed files with 19169 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package auth
import (
"net/http"
"time"
xhttp "github.com/zeromicro/x/http"
"tianyuan-api/apps/gateway/internal/svc"
)
func LogoutHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// 设置空的JWT Cookie覆盖之前的JWT
http.SetCookie(w, &http.Cookie{
Name: "Authorization", // 你的JWT cookie名
Value: "", // 清空cookies
Path: "/",
HttpOnly: true,
Expires: time.Unix(0, 0), // 过期时间设置为过去
})
xhttp.JsonBaseResponseCtx(r.Context(), w, nil)
}
}