Browse Source

登录修改

wangkaiyue 6 years ago
parent
commit
3abc5a50a5

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

@@ -546,7 +546,7 @@ func (f *Front) Login(key string) error {
 			f.SetSession("nickname", nick)
 			f.SetSession("s_nickname", nick)
 			f.SetSession("s_m_openid", fmt.Sprint((*user)["s_m_openid"]))
-			f.SetSession("userId", fmt.Sprint((*user)["_id"]))
+			f.SetSession("userId", util.BsonIdToSId((*user)["_id"]))
 			f.SetSession("user", *user)
 		} else {
 			f.ServeJson(map[string]string{
@@ -563,6 +563,7 @@ func (f *Front) Login(key string) error {
 
 //用户是否登录
 func (f *Front) HasSign() error {
+	log.Println("into~~~~~~~~~~~~~~~~~~~~~~~~")
 	tmp := f.Session().Get("user")
 	openid := f.GetSession("s_m_openid")
 	if openid == nil {
@@ -582,6 +583,7 @@ func (f *Front) HasSign() error {
 			"encryptId":    se.EncodeString(util.BsonIdToSId(user["_id"])),
 		})
 	}
+	log.Println("end~~~~~~~~~~~~~~~~~~~~~~")
 	return nil
 }
 

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

@@ -77,6 +77,7 @@ func (s *Short) Article(stype, id string) error {
 		client := s.Header("User-Agent")
 		bm = mobileReg.MatchString(client)
 		if s.Session().Get("userId") == nil { //} && !regclient.MatchString(client) { //没有用户session //搜索引擎让过
+			fmt.Println("userId==============nil")
 			s.Session().Set("referer", s.Request.RequestURI)
 			if bm { //是否是移动端访问
 				s.Redirect(aboutUrl, 302)
@@ -177,6 +178,7 @@ func (s *Short) Article(stype, id string) error {
 	} else {
 		sids := util.CommonDecodeArticle(stype, id)
 		if len(sids) == 0 {
+			fmt.Println("CommonDecodeArticle ==0")
 			s.Redirect("/notin/page", 302)
 			return nil
 		}

+ 4 - 3
src/jfw/front/websocket.go

@@ -157,6 +157,7 @@ func LoginInfo(shareid, openid string, Sess interface{}) (infoData map[string]in
 			sess.Set("s_nickname", nick)
 			sess.Set("s_m_openid", fmt.Sprint((*user)["s_m_openid"]))
 			sess.Set("user", *user)
+			sess.Set("userId", qutil.BsonIdToSId((*user)["_id"]))
 			sess.Set("rpcBackUserInfo", infoData)
 		}
 	}
@@ -269,10 +270,10 @@ func QrToShareTimeline(conn *websocket.Conn) {
 	var receive string
 	//接收消息
 	sess := xweb.RootApp().SessionManager.Session(conn.R, conn.W)
-	openid, _ := sess.Get("s_m_openid").(string)
+	userid, _ := sess.Get("userId").(string)
 	key := ""
-	if openid != "" {
-		key = fmt.Sprintf("pcbiddetail_shareTimeline_%s", openid)
+	if userid != "" {
+		key = fmt.Sprintf("pcbiddetail_shareTimeline_%s", userid)
 	}
 	go func() {
 		defer qutil.Catch()

+ 1 - 0
src/jfw/modules/weixin/src/wx/wx.go

@@ -842,6 +842,7 @@ func ScanHandler(w ResponseWriter, r *Request) {
 	if isRepeatCall(openid, r.CreateTime) {
 		return
 	}
+	log.Println("openid======", openid)
 	m, b := tools.MQFW.FindOneByField("user", `{"s_m_openid":"`+openid+`"}`, `{"_id":1,"s_headimage":1,"o_jy":1}`)
 	if b {
 		pccodepre := "0"