base.go 409 B

1234567891011121314151617181920212223
  1. package controller
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "net/http"
  5. "x-ui/web/session"
  6. )
  7. type BaseController struct {
  8. }
  9. func (a *BaseController) checkLogin(c *gin.Context) {
  10. if !session.IsLogin(c) {
  11. if isAjax(c) {
  12. pureJsonMsg(c, false, "登录时效已过,请重新登录")
  13. } else {
  14. c.Redirect(http.StatusTemporaryRedirect, c.GetString("base_path"))
  15. }
  16. c.Abort()
  17. } else {
  18. c.Next()
  19. }
  20. }