wangchuanjin 1 rok temu
rodzic
commit
a460be8049

+ 1 - 1
src/jfw/active/active_future.go

@@ -39,7 +39,7 @@ func (a *Active) FutureIndex(share_openid string) error {
 				if code != "" {
 					openid = jyutil.Getopenid(code)
 					if openid != "" {
-						FindUserAndCreateSess(a.Request, openid, a.Session(), "wx", false, true)
+						FindUserAndCreateSess(openid, a.Session(), "wx", false, true)
 					}
 				}
 			} else {

+ 1 - 1
src/jfw/active/active_seal.go

@@ -255,7 +255,7 @@ func (a *Active) Index() error {
 				if code != "" {
 					openid := jyutil.Getopenid(code)
 					if openid != "" {
-						FindUserAndCreateSess(a.Request, openid, a.Session(), "wx", false, true)
+						FindUserAndCreateSess(openid, a.Session(), "wx", false, true)
 					}
 				}
 			} else {

+ 1 - 1
src/jfw/active/live.go

@@ -128,7 +128,7 @@ func (this *Active) LivePage() error {
 						checkIsSubscribeFlag = CheckUserIsSubscribe(openid)
 						if checkIsSubscribeFlag {
 							//关注用户 建session
-							go FindUserAndCreateSess(this.Request, openid, this.Session(), "wx", false, true)
+							go FindUserAndCreateSess(openid, this.Session(), "wx", false, true)
 						}
 					}
 				}

+ 4 - 4
src/jfw/filter/pcfilter.go

@@ -4,7 +4,6 @@ import (
 	"fmt"
 	"jy/src/jfw/config"
 	"jy/src/jfw/jyutil"
-	"log"
 	"net/http"
 	"strings"
 	"time"
@@ -34,11 +33,13 @@ func (this *pcFilter) Do() bool {
 	if this.R.Method == "POST" {
 		return true
 	}
-	log.Println(this.R.RequestURI, "---", this.R.UserAgent())
-	if userAgent := this.R.UserAgent(); mobileReg.MatchString(userAgent) || public.CheckWxBrowser(this.R) || strings.Contains(userAgent, "JianyuDebug") {
+	if userAgent := this.R.UserAgent(); mobileReg.MatchString(userAgent) || public.CheckWxBrowser(this.R) {
 		//wx
 		return true
 	}
+	if strings.HasPrefix(string(this.Session.Id()), "JianyuDebug") {
+		return true
+	}
 	//企业搜索
 	if strings.Contains(this.R.RequestURI, "/jylab/entSearch/index.html") ||
 		strings.Contains(this.R.RequestURI, "/swordfish/page_big_pc/ent_portrait/") ||
@@ -77,7 +78,6 @@ func (this *pcFilter) Do() bool {
 	} else {
 		return true
 	}
-	log.Println(this.R.RequestURI, "---", this.Session.Id(), "==========cccccccccccccc", this.R.UserAgent())
 	http.Redirect(this.W, this.R, href, 302)
 	return false
 }

+ 1 - 1
src/jfw/filter/sesssionKeep.go

@@ -31,7 +31,7 @@ func (sk *SessionKeep) Do() bool {
 			baseUserIdStr := encrypt.SE.DecodeString(ck.Value)
 			if baseUserId, _ = strconv.ParseInt(baseUserIdStr, 10, 64); baseUserId > 0 {
 				//模拟登录 更新用户session
-				front.FindUserAndCreateSessByBaseUserId(sk.R, baseUserId, sk.Session, false, true)
+				front.FindUserAndCreateSessByBaseUserId(baseUserId, sk.Session, false, true)
 			}
 		}
 	}

+ 1 - 1
src/jfw/front/applysub.go

@@ -200,7 +200,7 @@ func (a *Applysub) Index() error {
 			if code != "" {
 				openid = jyutil.Getopenid(code)
 				if openid != "" {
-					FindUserAndCreateSess(a.Request, openid, a.Session(), "wx", false, true)
+					FindUserAndCreateSess(openid, a.Session(), "wx", false, true)
 				}
 			}
 		} else {

+ 1 - 1
src/jfw/front/commonPayWx.go

@@ -105,7 +105,7 @@ func (w *WxPayCommon) ToMyWxOrder() error {
 				openid := jyutil.Getopenid(code)
 				if openid != "" {
 					if CheckUserIsSubscribe(openid) {
-						FindUserAndCreateSess(w.Request, openid, w.Session(), "wx", false, true)
+						FindUserAndCreateSess(openid, w.Session(), "wx", false, true)
 					}
 				}
 			}

+ 4 - 4
src/jfw/front/distribution.go

@@ -46,7 +46,7 @@ func (this *Distrib) LinkShare(discored string) error {
 					checkIsSubscribeFlag = CheckUserIsSubscribe(openid)
 					if checkIsSubscribeFlag {
 						//关注用户 建session
-						FindUserAndCreateSess(this.Request, openid, this.Session(), "wx", false, true)
+						FindUserAndCreateSess(openid, this.Session(), "wx", false, true)
 					}
 				}
 			}
@@ -94,7 +94,7 @@ func (this *Distrib) LinkShareX(discored string) error {
 					checkIsSubscribeFlag = CheckUserIsSubscribe(openid)
 					if checkIsSubscribeFlag {
 						//关注用户 建session
-						FindUserAndCreateSess(this.Request, openid, this.Session(), "wx", false, true)
+						FindUserAndCreateSess(openid, this.Session(), "wx", false, true)
 					}
 				}
 			}
@@ -142,7 +142,7 @@ func (this *Distrib) LinkShareG(discored string) error {
 					checkIsSubscribeFlag = CheckUserIsSubscribe(openid)
 					if checkIsSubscribeFlag {
 						//关注用户 建session
-						FindUserAndCreateSess(this.Request, openid, this.Session(), "wx", false, true)
+						FindUserAndCreateSess(openid, this.Session(), "wx", false, true)
 					}
 				}
 			}
@@ -192,7 +192,7 @@ func (this *Distrib) LinkShareE(discored string) error {
 					checkIsSubscribeFlag = CheckUserIsSubscribe(openid)
 					if checkIsSubscribeFlag {
 						//关注用户 建session
-						FindUserAndCreateSess(this.Request, openid, this.Session(), "wx", false, true)
+						FindUserAndCreateSess(openid, this.Session(), "wx", false, true)
 					}
 				}
 			}

+ 1 - 1
src/jfw/front/follow.go

@@ -1583,7 +1583,7 @@ func (this *Follow) FollowGift(shareid string) error {
 						openid = jyutil.Getopenid(code)
 						if openid != "" {
 							if CheckUserIsSubscribe(openid) {
-								FindUserAndCreateSess(this.Request, openid, this.Session(), "wx", false, true)
+								FindUserAndCreateSess(openid, this.Session(), "wx", false, true)
 							}
 						}
 					}

+ 12 - 16
src/jfw/front/front.go

@@ -9,7 +9,6 @@ import (
 	"jy/src/jfw/wx"
 	"log"
 	"math/rand"
-	"net/http"
 	"net/url"
 	"regexp"
 	"strconv"
@@ -622,7 +621,7 @@ func (f *Front) Login(key string) error {
 	shareid := se.DecodeString(key)
 	openid := redis.GetStr("sso", "p_usershare_"+shareid)
 	if openid != "" {
-		ok, user, userInfo := FindUserAndCreateSess(f.Request, openid, f.Session(), "pc", true, true)
+		ok, user, userInfo := FindUserAndCreateSess(openid, f.Session(), "pc", true, true)
 		if ok {
 			(*user)["shareid"] = shareid
 			f.SetSession("user", *user)
@@ -808,27 +807,27 @@ func (m *Front) Wxerr() error {
 }
 
 // 查找用户并创建session
-func FindUserAndCreateSess(request *http.Request, openid string, sess *httpsession.Session, typ string, flag, isSwitchToBestIdentity bool) (bool, *map[string]interface{}, map[string]interface{}) {
-	return CreateSession(request, map[string]interface{}{
+func FindUserAndCreateSess(openid string, sess *httpsession.Session, typ string, flag, isSwitchToBestIdentity bool) (bool, *map[string]interface{}, map[string]interface{}) {
+	return CreateSession(map[string]interface{}{
 		"s_m_openid": openid,
 		"s_unionid":  map[string]interface{}{"$ne": openid}, //处理排除未关注用户点击菜单创建的用户
 		"i_ispush":   1,
 	}, sess, typ, flag, isSwitchToBestIdentity)
 }
-func FindUserAndCreateSessByBaseUserId(request *http.Request, userId int64, sess *httpsession.Session, flag, isSwitchToBestIdentity bool) (bool, *map[string]interface{}, map[string]interface{}) {
-	return CreateSession(request, map[string]interface{}{
+func FindUserAndCreateSessByBaseUserId(userId int64, sess *httpsession.Session, flag, isSwitchToBestIdentity bool) (bool, *map[string]interface{}, map[string]interface{}) {
+	return CreateSession(map[string]interface{}{
 		"base_user_id": userId,
 	}, sess, "pc", flag, isSwitchToBestIdentity)
 
 }
 
-func FindUserAndCreateSessById(request *http.Request, userId primitive.ObjectID, sess *httpsession.Session, flag, isSwitchToBestIdentity bool) (bool, *map[string]interface{}, map[string]interface{}) {
-	return CreateSession(request, map[string]interface{}{
+func FindUserAndCreateSessById(userId primitive.ObjectID, sess *httpsession.Session, flag, isSwitchToBestIdentity bool) (bool, *map[string]interface{}, map[string]interface{}) {
+	return CreateSession(map[string]interface{}{
 		"_id": userId,
 	}, sess, "pc", flag, isSwitchToBestIdentity)
 }
 
-func CreateSession(request *http.Request, q map[string]interface{}, sess *httpsession.Session, typ string, flag, isSwitchToBestIdentity bool) (bool, *map[string]interface{}, map[string]interface{}) {
+func CreateSession(q map[string]interface{}, sess *httpsession.Session, typ string, flag, isSwitchToBestIdentity bool) (bool, *map[string]interface{}, map[string]interface{}) {
 	if q == nil || len(q) == 0 {
 		return false, nil, nil
 	}
@@ -837,10 +836,7 @@ func CreateSession(request *http.Request, q map[string]interface{}, sess *httpse
 		return false, nil, nil
 	}
 	userid := util.ObjToString(sessionVal["userId"])
-	if request != nil && strings.Contains(request.UserAgent(), "JianyuDebug") {
-		flag = false
-	}
-	if pcSessionFlag, ok := config.Sysconfig["pcSessionFlag"].(bool); pcSessionFlag && ok && flag {
+	if pcSessionFlag, ok := config.Sysconfig["pcSessionFlag"].(bool); pcSessionFlag && ok && flag && !strings.HasPrefix(string(sess.Id()), "JianyuDebug") {
 		//无限制登陆用户
 		if util.IntAll(sessionVal["i_unlimited"]) <= 0 {
 			redis.Put("other", jyutil.LoginRedisKey(userid), sess.Id(), 3600*util.IntAllDef(config.Sysconfig["pcSessionTimeout"], 168))
@@ -900,18 +896,18 @@ func (m *Front) Sess(ostr string) error {
 					identity = config.Middleground.UserCenter.IdentityByPositionId(util.Int64All(userFlag))
 				}
 				if identity != nil {
-					ok, _, _ = FindUserAndCreateSessByBaseUserId(m.Request, identity.UserId, m.Session(), false, false)
+					ok, _, _ = FindUserAndCreateSessByBaseUserId(identity.UserId, m.Session(), false, false)
 				}
 			} else {
 				hasIdentity := false
 				if str[1] == "_id" {
-					if ok, _, _ = FindUserAndCreateSessById(m.Request, mgdb.StringTOBsonId(userFlag), m.Session(), false, !hasIdentity); ok {
+					if ok, _, _ = FindUserAndCreateSessById(mgdb.StringTOBsonId(userFlag), m.Session(), false, !hasIdentity); ok {
 						hasIdentity = true
 					}
 				} else {
 					//P387用户身份及搜索模式优化-微信公众号点击菜单重新获取上次身份
 					if userFlag != "" {
-						if ok, _, _ = FindUserAndCreateSess(m.Request, userFlag, m.Session(), "wx", false, !hasIdentity); ok {
+						if ok, _, _ = FindUserAndCreateSess(userFlag, m.Session(), "wx", false, !hasIdentity); ok {
 							hasIdentity = true
 						}
 					}

+ 1 - 1
src/jfw/front/frontRouter.go

@@ -86,7 +86,7 @@ func (this *CommonRouter) WxCommonPage(folder, loginSign, htmlPage string) error
 				return this.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(this.Site()+this.Url()), "wx"), 302)
 			}
 			openid = jyutil.Getopenid(this.GetString("code"))
-			if ok, _, _ := FindUserAndCreateSess(this.Request, openid, this.Session(), "wx", false, true); !ok {
+			if ok, _, _ := FindUserAndCreateSess(openid, this.Session(), "wx", false, true); !ok {
 				return this.Redirect("/swordfish/about")
 			}
 		}

+ 1 - 1
src/jfw/front/login.go

@@ -481,7 +481,7 @@ func afterLogin(request *http.Request, phone string, session *httpsession.Sessio
 	if user == nil || len(user) == 0 {
 		return false, nil, nil
 	}
-	return FindUserAndCreateSessById(request, user["_id"].(primitive.ObjectID), session, true, true)
+	return FindUserAndCreateSessById(user["_id"].(primitive.ObjectID), session, true, true)
 }
 
 func GetModule(source string) string {

+ 2 - 2
src/jfw/front/org_structure.go

@@ -96,7 +96,7 @@ func (this *OrgStructure) InvitationPage() error {
 			isSubscribe = CheckUserIsSubscribe(openId)
 			if isSubscribe {
 				registered = "1"
-				FindUserAndCreateSess(this.Request, openId, this.Session(), "wx", false, true)
+				FindUserAndCreateSess(openId, this.Session(), "wx", false, true)
 				phone = util.If(this.GetSession("phone") != nil, this.GetSession("phone"), "").(string)
 			}
 		}
@@ -124,7 +124,7 @@ func (this *OrgStructure) Authorize() error {
 	if openId != "" {
 		isSubscribe = CheckUserIsSubscribe(openId)
 		if isSubscribe {
-			FindUserAndCreateSess(this.Request, openId, this.Session(), "wx", false, true)
+			FindUserAndCreateSess(openId, this.Session(), "wx", false, true)
 		} else { //获取未关注用户uninoid
 			unionId = GetUnionid(openId)
 		}

+ 1 - 1
src/jfw/front/pchelper.go

@@ -309,7 +309,7 @@ func (l *PcHelper) ToAct(token string) error {
 				if phone != "" && deMac != "" {
 					if len([]rune(phone)) == 11 {
 						//PcHelperLoginInfo(phone, l.Session())
-						CreateSession(l.Request, map[string]interface{}{
+						CreateSession(map[string]interface{}{
 							"i_appid": 2,
 							"s_phone": phone,
 						}, l.Session(), "pchelper", true, true)

+ 2 - 2
src/jfw/front/shorturl.go

@@ -141,7 +141,7 @@ func (s *Short) Article(stype, id string) error {
 				if code := s.GetString("code"); code != "" {
 					if openid := jyutil.Getopenid(code); openid != "" {
 						if CheckUserIsSubscribe(openid) {
-							FindUserAndCreateSess(s.Request, openid, s.Session(), "wx", false, true)
+							FindUserAndCreateSess(openid, s.Session(), "wx", false, true)
 							//生session后 重新获取一下
 							//userId, _ = s.GetSession("userId").(string)
 							sess = s.Session().GetMultiple()
@@ -450,7 +450,7 @@ func (s *Short) LoginCommon(sess map[string]interface{}, stype, id string, bm bo
 			}
 			//之前sessionkeep.go中没有放userId,造成关注有问题
 			if userId == "" {
-				FindUserAndCreateSess(s.Request, ssOpenid.(string), s.Session(), "wx", false, true)
+				FindUserAndCreateSess(ssOpenid.(string), s.Session(), "wx", false, true)
 			}
 		}
 		surl := s.GetString("url")

+ 3 - 3
src/jfw/front/singleLogin.go

@@ -55,7 +55,7 @@ func (this *SingleLogin) KeyPhrases(key string) error {
 				if code := this.GetString("code"); code != "" {
 					if openid := jyutil.Getopenid(code); openid != "" {
 						if CheckUserIsSubscribe(openid) {
-							FindUserAndCreateSess(this.Request, openid, this.Session(), "wx", false, true)
+							FindUserAndCreateSess(openid, this.Session(), "wx", false, true)
 							//生session后 重新获取一下
 							sess = this.Session().GetMultiple()
 							userId, _ = sess["userId"].(string)
@@ -73,7 +73,7 @@ func (this *SingleLogin) KeyPhrases(key string) error {
 			mgoUserId := qutil.InterfaceToStr(sess["mgoUserId"])
 			//身份切换
 			if positionType > 0 {
-				FindUserAndCreateSessById(this.Request, mgdb.StringTOBsonId(mgoUserId), this.Session(), false, false)
+				FindUserAndCreateSessById(mgdb.StringTOBsonId(mgoUserId), this.Session(), false, false)
 				identity := config.Middleground.UserCenter.IdentityByUserId(qutil.Int64All(this.GetSession("base_user_id")))
 				if identity != nil {
 					NewIdentityInfo(identity).Switch(this.Session(), &public.MQFW)
@@ -214,7 +214,7 @@ func (this *SingleLogin) SingleLogin() error {
 			}(id)
 		}
 		if this.GetSession("userId") == nil || this.GetSession("phone") == nil {
-			CreateSession(this.Request, map[string]interface{}{
+			CreateSession(map[string]interface{}{
 				"s_m_openid": openid,
 				"s_unionid":  map[string]interface{}{"$ne": openid}, //处理排除未关注用户点击菜单创建的用户
 			}, this.Session(), "singleLogin", false, true)

+ 1 - 1
src/jfw/front/swordfish.go

@@ -1390,7 +1390,7 @@ func (m *Front) About() error {
 	if myopenid != "" {
 		isSubscribe = CheckUserIsSubscribe(myopenid)
 		if isSubscribe {
-			FindUserAndCreateSess(m.Request, myopenid, m.Session(), "wx", false, true)
+			FindUserAndCreateSess(myopenid, m.Session(), "wx", false, true)
 			myopenid, _ = getsession["s_m_openid"].(string)
 			mynickname, _ = getsession["s_nickname"].(string)
 		}

+ 1 - 1
src/jfw/front/vipsubscribe.go

@@ -218,7 +218,7 @@ func (s *Subscribepay) Introduce() error {
 				if openid != "" {
 					isSubscribe := CheckUserIsSubscribe(openid)
 					if isSubscribe {
-						FindUserAndCreateSess(s.Request, openid, s.Session(), "wx", false, true)
+						FindUserAndCreateSess(openid, s.Session(), "wx", false, true)
 						userId = util.ObjToString(s.GetSession("userId"))
 					}
 				}

+ 1 - 1
src/jfw/front/websocket.go

@@ -174,7 +174,7 @@ func LoginInfo(shareid, openid string, Sess interface{}) map[string]interface{}
 	}
 	sess, _ := Sess.(*httpsession.Session)
 	if openid != "" {
-		ok, user, infoData := FindUserAndCreateSess(nil, openid, sess, "pc", true, true)
+		ok, user, infoData := FindUserAndCreateSess(openid, sess, "pc", true, true)
 		if ok {
 			(*user)["shareid"] = shareid
 			sess.Set("user", *user)

+ 3 - 3
src/jfw/front/ws_dataExport.go

@@ -56,7 +56,7 @@ func (w *WsDataExport) WxToOrderDetail() error {
 			if code != "" {
 				openid := jyutil.Getopenid(code)
 				if openid != "" {
-					FindUserAndCreateSess(w.Request, openid, w.Session(), "wx", false, true)
+					FindUserAndCreateSess(openid, w.Session(), "wx", false, true)
 				}
 			}
 		} else {
@@ -233,7 +233,7 @@ func (w *WsDataExport) ToPreview(_id string) error {
 			if code != "" {
 				openid = jyutil.Getopenid(code)
 				if openid != "" {
-					FindUserAndCreateSess(w.Request, openid, w.Session(), "wx", false, true)
+					FindUserAndCreateSess(openid, w.Session(), "wx", false, true)
 				}
 			}
 		} else {
@@ -263,7 +263,7 @@ func (w *WsDataExport) SubmitOrder() error {
 			if code != "" {
 				openid = jyutil.Getopenid(code)
 				if openid != "" {
-					FindUserAndCreateSess(w.Request, openid, w.Session(), "wx", false, true)
+					FindUserAndCreateSess(openid, w.Session(), "wx", false, true)
 				}
 			}
 		} else {