Skip to content

Commit

Permalink
feat: 发布v2.2.25
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Jul 12, 2024
1 parent f65cf9e commit 724610a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
20 changes: 19 additions & 1 deletion app/http/controllers/user_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,28 @@ func (r *UserController) Login(ctx http.Context) http.Response {
// @Success 200 {object} SuccessResponse
// @Router /panel/user/logout [post]
func (r *UserController) Logout(ctx http.Context) http.Response {
ctx.Request().Session().Forget("user_id")
if ctx.Request().HasSession() {
ctx.Request().Session().Forget("user_id")
}

return Success(ctx, nil)
}

// IsLogin
//
// @Summary 是否登录
// @Tags 用户鉴权
// @Produce json
// @Success 200 {object} SuccessResponse
// @Router /panel/user/isLogin [get]
func (r *UserController) IsLogin(ctx http.Context) http.Response {
if !ctx.Request().HasSession() {
return Success(ctx, false)
}

return Success(ctx, ctx.Request().Session().Has("user_id"))
}

// Info
//
// @Summary 用户信息
Expand Down
2 changes: 1 addition & 1 deletion config/panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func init() {
config := facades.Config()
config.Add("panel", map[string]any{
"name": "耗子面板",
"version": "v2.2.24",
"version": "v2.2.25",
"ssl": config.Env("APP_SSL", false),
// 安全入口
"entrance": config.Env("APP_ENTRANCE", "/"),
Expand Down
1 change: 1 addition & 0 deletions routes/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func Api() {
userController := controllers.NewUserController()
r.Middleware(frameworkmiddleware.Throttle("login")).Post("login", userController.Login)
r.Post("logout", userController.Logout)
r.Get("isLogin", userController.IsLogin)
r.Middleware(middleware.Session()).Get("info", userController.Info)
})
r.Prefix("task").Middleware(middleware.Session()).Group(func(r route.Router) {
Expand Down

0 comments on commit 724610a

Please sign in to comment.