refactor(auth): simplify admin session token flow

This commit is contained in:
mlogclub
2026-04-30 17:42:24 +08:00
parent e763a75f78
commit fbafb13a8a
12 changed files with 411 additions and 179 deletions
+1 -22
View File
@@ -30,20 +30,6 @@ func (c *AuthController) PostLogin() *web.JsonResult {
return web.JsonData(ret)
}
func (c *AuthController) PostRefresh_token() *web.JsonResult {
cfg := config.Current()
req := request.RefreshTokenRequest{}
if err := params.ReadJSON(c.Ctx, &req); err != nil {
return web.JsonError(err)
}
ret, err := services.AuthService.RefreshToken(req.RefreshToken, cfg.Auth, c.Ctx.RemoteAddr(), c.Ctx.GetHeader("User-Agent"))
if err != nil {
return web.JsonError(err)
}
return web.JsonData(ret)
}
func (c *AuthController) GetWxwork_login() {
loginURL, err := services.WxWorkLoginService.BuildWxWorkLoginURL(c.Ctx.URLParam("next"))
if err != nil {
@@ -91,14 +77,7 @@ func (c *AuthController) PostWxwork_exchange() *web.JsonResult {
}
func (c *AuthController) PostLogout() *web.JsonResult {
req := request.LogoutRequest{}
if c.Ctx.GetContentLength() > 0 {
if err := params.ReadJSON(c.Ctx, &req); err != nil {
return web.JsonError(err)
}
}
if err := services.AuthService.Logout(c.Ctx.GetHeader("Authorization"), req.RefreshToken); err != nil {
if err := services.AuthService.Logout(c.Ctx.GetHeader("Authorization")); err != nil {
return web.JsonError(err)
}
return web.JsonSuccess()