duxin 2 жил өмнө
parent
commit
a887c97587

+ 23 - 0
src/jfw/filter/anonymousUser.go

@@ -1,17 +1,21 @@
 package filter
 
 import (
+	util "app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/go-xweb/httpsession"
+	"app.yhyue.com/moapp/jypkg/public"
 	"crypto/rand"
 	"crypto/rsa"
 	"crypto/x509"
 	"encoding/base64"
+	"encoding/json"
 	"encoding/pem"
 	"errors"
 	"fmt"
 	"io/ioutil"
 	"log"
 	"net/http"
+	"time"
 )
 
 func initPrivatePublicKey() {
@@ -100,6 +104,25 @@ func AnonymousAuthentication(W http.ResponseWriter, R *http.Request, Session *ht
 			return
 		}
 		Session.Set("anonymousEid", eid.Value)
+		//未登录用户增加匿名身份信息
+		if Session.Get("mgoUserId") == nil || Session.Get("mgoUserId") == "" {
+			agent := R.Header.Get("user-agent")
+			md, _ := json.Marshal(R.Form)
+			str := string(md)
+			data := map[string]interface{}{
+				"ip":            util.GetIp(R),
+				"client":        agent,
+				"os":            util.GetOS(agent),
+				"browse":        util.GetBrowse(agent),
+				"fid":           fid,
+				"url":           R.RequestURI,
+				"mdescribe":     str,
+				"refer":         R.Referer(),
+				"method":        R.Method,
+				"creation_time": time.Now().Unix(),
+			}
+			public.BaseMysql.Insert("anonymous_identity", data)
+		}
 	} else {
 		log.Println("无身份验证信息")
 	}