|
@@ -1080,18 +1080,14 @@ func returnFront(m *Member, key string) error {
|
|
|
}
|
|
|
|
|
|
//更新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{}) {
|
|
|
freeze := IntAll(r["i_freeze"])
|
|
|
action.Session().Set("i_freeze", freeze)
|
|
|
if r["s_nickname"] == nil || r["s_nickname"].(string) == "" {
|
|
|
bindweixin := "qmx-" + fmt.Sprintf("%d%d", time.Now().Local().Unix(), rand.Intn(99))
|
|
|
action.SetSession("nickName", bindweixin)
|
|
|
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 {
|
|
|
action.SetSession("nickName", r["s_nickname"])
|
|
@@ -1103,14 +1099,14 @@ func UpdateCookieSession(action *xweb.Action, loginType string, flag bool, m map
|
|
|
}
|
|
|
action.App.SessionManager.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.SetSession("loginName", r[loginType])
|
|
|
action.SetSession("loginType", loginType)
|
|
|
UpdateSession(action, r)
|
|
|
_, err := action.GetCookie("USER_INFO")
|
|
|
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)}
|
|
|
action.SetCookie(cookie_userName)
|
|
|
}
|