logoutHandler.go 594 B

123456789101112131415161718192021222324
  1. // Code scaffolded by goctl. Safe to edit.
  2. // goctl 1.10.0
  3. package auth
  4. import (
  5. "net/http"
  6. "github.com/zeromicro/go-zero/rest/httpx"
  7. "perms-system-server/internal/logic/auth"
  8. "perms-system-server/internal/svc"
  9. )
  10. // LogoutHandler 用户注销接口。使所有已签发令牌立即失效并清除缓存。
  11. func LogoutHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  12. return func(w http.ResponseWriter, r *http.Request) {
  13. l := auth.NewLogoutLogic(r.Context(), svcCtx)
  14. err := l.Logout()
  15. if err != nil {
  16. httpx.ErrorCtx(r.Context(), w, err)
  17. } else {
  18. httpx.Ok(w)
  19. }
  20. }
  21. }