|
@@ -1080,18 +1080,15 @@ func returnFront(m *Member, key string) error {
|
|
}
|
|
}
|
|
|
|
|
|
//更新cookie sessoin
|
|
//更新cookie sessoin
|
|
-func UpdateCookieSession(action *xweb.Action, loginType string, flag bool, m map[string]interface{}) {
|
|
|
|
- r := make(map[string]interface{})
|
|
|
|
- if d, err := json.Marshal(m); err != nil || json.Unmarshal(d, &r) != nil {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
|
|
+func UpdateCookieSession(action *xweb.Action, loginType string, flag bool, r map[string]interface{}) {
|
|
|
|
+ log.Println(r)
|
|
freeze := IntAll(r["i_freeze"])
|
|
freeze := IntAll(r["i_freeze"])
|
|
action.Session().Set("i_freeze", freeze)
|
|
action.Session().Set("i_freeze", freeze)
|
|
if r["s_nickname"] == nil || r["s_nickname"].(string) == "" {
|
|
if r["s_nickname"] == nil || r["s_nickname"].(string) == "" {
|
|
bindweixin := "qmx-" + fmt.Sprintf("%d%d", time.Now().Local().Unix(), rand.Intn(99))
|
|
bindweixin := "qmx-" + fmt.Sprintf("%d%d", time.Now().Local().Unix(), rand.Intn(99))
|
|
action.SetSession("nickName", bindweixin)
|
|
action.SetSession("nickName", bindweixin)
|
|
go func() {
|
|
go func() {
|
|
- Update("user", `{"_id":"`+r["_id"].(string)+`"}`, `{"$set":{"s_nickname":"`+bindweixin+`"}}`, false, false)
|
|
|
|
|
|
+ Update("user", `{"_id":"`+BsonIdToSId(r["_id"])+`"}`, `{"$set":{"s_nickname":"`+bindweixin+`"}}`, false, false)
|
|
}()
|
|
}()
|
|
} else {
|
|
} else {
|
|
action.SetSession("nickName", r["s_nickname"])
|
|
action.SetSession("nickName", r["s_nickname"])
|
|
@@ -1103,14 +1100,14 @@ func UpdateCookieSession(action *xweb.Action, loginType string, flag bool, m map
|
|
}
|
|
}
|
|
action.App.SessionManager.SetMaxAge(30 * time.Minute)
|
|
action.App.SessionManager.SetMaxAge(30 * time.Minute)
|
|
action.Session().SetMaxAge(30 * time.Minute)
|
|
action.Session().SetMaxAge(30 * time.Minute)
|
|
- action.Session().Set("id", r["_id"])
|
|
|
|
|
|
+ action.Session().Set("id", BsonIdToSId(r["_id"]))
|
|
action.Session().Set("identWay", IntAll(r["i_identificationway"]))
|
|
action.Session().Set("identWay", IntAll(r["i_identificationway"]))
|
|
action.SetSession("loginName", r[loginType])
|
|
action.SetSession("loginName", r[loginType])
|
|
action.SetSession("loginType", loginType)
|
|
action.SetSession("loginType", loginType)
|
|
UpdateSession(action, r)
|
|
UpdateSession(action, r)
|
|
_, err := action.GetCookie("USER_INFO")
|
|
_, err := action.GetCookie("USER_INFO")
|
|
if flag || err == nil {
|
|
if flag || err == nil {
|
|
- userInfo, _ := json.Marshal(map[string]interface{}{"loginId": r["_id"], "loginType": loginType})
|
|
|
|
|
|
+ userInfo, _ := json.Marshal(map[string]interface{}{"loginId": BsonIdToSId(r["_id"]), "loginType": loginType})
|
|
cookie_userName := &http.Cookie{Name: "USER_INFO", Value: base64.StdEncoding.EncodeToString(userInfo), Path: "/", Expires: time.Now().AddDate(0, 0, 7)}
|
|
cookie_userName := &http.Cookie{Name: "USER_INFO", Value: base64.StdEncoding.EncodeToString(userInfo), Path: "/", Expires: time.Now().AddDate(0, 0, 7)}
|
|
action.SetCookie(cookie_userName)
|
|
action.SetCookie(cookie_userName)
|
|
}
|
|
}
|
|
@@ -1123,7 +1120,7 @@ func UpdateSession(action *xweb.Action, r map[string]interface{}) {
|
|
if r["s_nickname"] != nil && r["s_nickname"].(string) != "" {
|
|
if r["s_nickname"] != nil && r["s_nickname"].(string) != "" {
|
|
setSessMap["nickName"] = r["s_nickname"]
|
|
setSessMap["nickName"] = r["s_nickname"]
|
|
}
|
|
}
|
|
- setSessMap["userId"] = r["_id"]
|
|
|
|
|
|
+ setSessMap["userId"] = BsonIdToSId(r["_id"])
|
|
setSessMap["s_m_openid"] = r["s_m_openid"]
|
|
setSessMap["s_m_openid"] = r["s_m_openid"]
|
|
setSessMap["userType"] = IntAllDef(r["i_type"], 2)
|
|
setSessMap["userType"] = IntAllDef(r["i_type"], 2)
|
|
setSessMap["userInfo"] = &r
|
|
setSessMap["userInfo"] = &r
|
|
@@ -1163,7 +1160,7 @@ func UpdateSession(action *xweb.Action, r map[string]interface{}) {
|
|
action.SetSession("identWay", IntAll(r["i_identificationway"])) //认证状态
|
|
action.SetSession("identWay", IntAll(r["i_identificationway"])) //认证状态
|
|
action.SetSession("opLocDistrict", r["opLocDistrict"]) //行政区划代码
|
|
action.SetSession("opLocDistrict", r["opLocDistrict"]) //行政区划代码
|
|
**/
|
|
**/
|
|
- action.Session().UpdateByCustomField("id", r["_id"], "", &setSessMap)
|
|
|
|
|
|
+ action.Session().UpdateByCustomField("id", BsonIdToSId(r["_id"]), "", &setSessMap)
|
|
}, func(e interface{}) {
|
|
}, func(e interface{}) {
|
|
log.Println("登录报错", e)
|
|
log.Println("登录报错", e)
|
|
})
|
|
})
|