add: user auth accomplished

This commit is contained in:
wwweww
2026-02-26 02:17:07 +08:00
parent 300058ad01
commit 60b6f40f9f
54 changed files with 1601 additions and 2303 deletions
@@ -4,12 +4,12 @@
package user
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/users/api/internal/logic/user"
"juwan-backend/app/users/api/internal/svc"
"juwan-backend/app/users/api/internal/types"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
)
// 用户登录接口
@@ -23,6 +23,22 @@ func LoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
l := user.NewLoginLogic(r.Context(), svcCtx)
resp, err := l.Login(&req)
token := resp.Token
resp.Token = ""
http.SetCookie(w, &http.Cookie{
Name: "JToken",
Value: token,
Quoted: false,
Path: "/",
Domain: "",
RawExpires: "",
MaxAge: 691200,
Secure: false,
HttpOnly: true,
SameSite: http.SameSiteStrictMode,
Partitioned: false,
})
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {