2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 12:40:25 +08:00

feat: 发布v2.2.25

This commit is contained in:
耗子
2024-07-13 04:17:45 +08:00
parent f65cf9e38e
commit 724610a45d
3 changed files with 21 additions and 2 deletions

View File

@@ -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 用户信息

View File

@@ -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", "/"),

View File

@@ -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) {