v1.2.0 修改jwt有效期和获取token接口
This commit is contained in:
@@ -246,6 +246,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
Path: "/user/detail",
|
||||
Handler: user.DetailHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// get new token
|
||||
Method: http.MethodPost,
|
||||
Path: "/user/getToken",
|
||||
Handler: user.GetTokenHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret),
|
||||
rest.WithPrefix("/api/v1"),
|
||||
|
||||
17
app/user/cmd/api/internal/handler/user/gettokenhandler.go
Normal file
17
app/user/cmd/api/internal/handler/user/gettokenhandler.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"qnc-server/app/user/cmd/api/internal/logic/user"
|
||||
"qnc-server/app/user/cmd/api/internal/svc"
|
||||
"qnc-server/common/result"
|
||||
)
|
||||
|
||||
func GetTokenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := user.NewGetTokenLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetToken()
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user