|
@@ -2,6 +2,8 @@ package middleware
|
|
|
|
|
|
import (
|
|
|
elastic "app.yhyue.com/moapp/jybase/es"
|
|
|
+ "strings"
|
|
|
+
|
|
|
//. "app.yhyue.com/moapp/jybase/api"
|
|
|
"context"
|
|
|
"fmt"
|
|
@@ -92,33 +94,35 @@ func (s *sMiddleware) LoginFilter(r *ghttp.Request) {
|
|
|
uMsg *model.User
|
|
|
err error
|
|
|
)
|
|
|
- if token := r.Header.Get("Token"); token != "" {
|
|
|
- uMsg, err = jyutil.GetUserMsgFromToken(r.Context(), token)
|
|
|
- if err != nil {
|
|
|
- r.SetError(fmt.Errorf("无效token"))
|
|
|
+ if !strings.HasPrefix(r.RequestURI, "/debug") {
|
|
|
+ if token := r.Header.Get("Token"); token != "" {
|
|
|
+ uMsg, err = jyutil.GetUserMsgFromToken(r.Context(), token)
|
|
|
+ if err != nil {
|
|
|
+ r.SetError(fmt.Errorf("无效token"))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ uMsg = &model.User{
|
|
|
+ PositionId: r.Session.MustGet("positionId", 0).Int64(),
|
|
|
+ EntUserId: r.Session.MustGet("entUserId", 0).Int64(),
|
|
|
+ EntId: r.Session.MustGet("entId", 0).Int64(),
|
|
|
+ EntDeptId: r.Session.MustGet("entDeptId", 0).Int64(),
|
|
|
+ EntRole: r.Session.MustGet("entRole", 0).Int64(),
|
|
|
+ AccountId: r.Session.MustGet("accountId", 0).Int64(),
|
|
|
+ //MgoUserId: r.Session.MustGet("mgoUserId", 0).String(),
|
|
|
+ EntUserName: r.Session.MustGet("entUserName", "").String(),
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if uMsg == nil || uMsg.EntId == 0 || uMsg.EntUserId == 0 {
|
|
|
+ r.SetError(fmt.Errorf("身份异常"))
|
|
|
return
|
|
|
}
|
|
|
- } else {
|
|
|
- uMsg = &model.User{
|
|
|
- PositionId: r.Session.MustGet("positionId", 0).Int64(),
|
|
|
- EntUserId: r.Session.MustGet("entUserId", 0).Int64(),
|
|
|
- EntId: r.Session.MustGet("entId", 0).Int64(),
|
|
|
- EntDeptId: r.Session.MustGet("entDeptId", 0).Int64(),
|
|
|
- EntRole: r.Session.MustGet("entRole", 0).Int64(),
|
|
|
- AccountId: r.Session.MustGet("accountId", 0).Int64(),
|
|
|
- //MgoUserId: r.Session.MustGet("mgoUserId", 0).String(),
|
|
|
- EntUserName: r.Session.MustGet("entUserName", "").String(),
|
|
|
+ if uMsg.EntId != g.Cfg("global").MustGet(r.Context(), "powerEntId", 25917).Int64() {
|
|
|
+ r.SetError(fmt.Errorf("非法请求"))
|
|
|
+ return
|
|
|
}
|
|
|
+ r.SetCtxVar(consts.ContextKey, uMsg)
|
|
|
}
|
|
|
- if uMsg == nil || uMsg.EntId == 0 || uMsg.EntUserId == 0 {
|
|
|
- r.SetError(fmt.Errorf("身份异常"))
|
|
|
- return
|
|
|
- }
|
|
|
- if uMsg.EntId != g.Cfg("global").MustGet(r.Context(), "powerEntId", 25917).Int64() {
|
|
|
- r.SetError(fmt.Errorf("非法请求"))
|
|
|
- return
|
|
|
- }
|
|
|
- r.SetCtxVar(consts.ContextKey, uMsg)
|
|
|
r.Middleware.Next()
|
|
|
}
|
|
|
|