|
@@ -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
|
|
|
}
|
|
|
}
|