|
@@ -51,7 +51,6 @@ type Login struct {
|
|
|
afterPageLoadToCheck xweb.Mapper `xweb:"/jyapp/free/afterPageLoadToCheck"` //检测
|
|
|
channelSign xweb.Mapper `xweb:"/jyapp/free/channelSign"` //渠道统计
|
|
|
savePushIdMsg xweb.Mapper `xweb:"/jyapp/free/savePushIdMsg"` //推送id记录
|
|
|
- tes xweb.Mapper `xweb:"/jyapp/free/tes"`
|
|
|
}
|
|
|
|
|
|
var (
|
|
@@ -71,14 +70,7 @@ func init() {
|
|
|
}
|
|
|
go rs.GC()
|
|
|
}
|
|
|
-func (l *Login) Tes() {
|
|
|
- //uid: 5d9fe93a27573439d033b294 QQtJCABNAVEDAkFYQ1pWTVYAAgYWXUla
|
|
|
- // u_secure := BsonIdToSId(person["_id"]) //Ql9FD1wRUFNQVENfEgoGRQQCUlFHCUNa
|
|
|
- // simpleuid := qutil.SE.EncodeString(BsonIdToSId(person["_id"]))
|
|
|
- // log.Println("uid:", u_secure, simpleuid)
|
|
|
- log.Println(qutil.SE.DecodeString("Ql9FD1wRUFNQVENfEgoGRQQCUlFHCUNa"))
|
|
|
- log.Println(qutil.SE.DecodeString("QQtJCABNAVEDAkFYQ1pWTVYAAgYWXUla"))
|
|
|
-}
|
|
|
+
|
|
|
func (l *Login) Login() error {
|
|
|
defer qutil.Catch()
|
|
|
if l.Method() == "GET" {
|
|
@@ -756,6 +748,7 @@ func (l *Login) SignOut() {
|
|
|
}
|
|
|
}()
|
|
|
}
|
|
|
+ jy.DelUnlimitSessionId(fmt.Sprint(l.Session().Id()), userid) //多账号
|
|
|
ClearSession(l.Session())
|
|
|
l.ServeJson(map[string]interface{}{
|
|
|
"status": status,
|
|
@@ -833,7 +826,7 @@ func (l *Login) AfterPageLoadToCheck() {
|
|
|
},
|
|
|
"$pull": map[string]interface{}{"a_jpushid": rid},
|
|
|
})
|
|
|
- sign = createSign(userId, rid, "更新极光id后")
|
|
|
+ sign = createSign(userId, rid, "更新极光id后", l.Session())
|
|
|
}
|
|
|
l.ServeJson(map[string]interface{}{
|
|
|
"status": status,
|
|
@@ -849,7 +842,7 @@ func (l *Login) Brand() {
|
|
|
if !checkIsKicked(false, u.UserId, u.Rid, l.Session()) {
|
|
|
jgPushId := l.GetString("jgPushId")
|
|
|
setMobileInfo(u.UserId, l.GetString("phoneBrand"), l.GetString("pushToken"), jgPushId)
|
|
|
- sign = createSign(u.UserId, jgPushId, "设置手机类型和推送id后")
|
|
|
+ sign = createSign(u.UserId, jgPushId, "设置手机类型和推送id后", l.Session())
|
|
|
}
|
|
|
}
|
|
|
l.ServeJson(map[string]interface{}{
|
|
@@ -920,7 +913,7 @@ func createSession(s *httpsession.Session, person map[string]interface{}, loginI
|
|
|
default:
|
|
|
return false
|
|
|
}
|
|
|
- field := `{"s_m_openid":1,"s_phone":1,"s_jpushid":1,"s_opushid":1,"s_appponetype":1,"s_headimageurl":1,"s_phone":1,"s_nickname":1,"s_appversion":1}`
|
|
|
+ field := `{"s_m_openid":1,"s_phone":1,"s_jpushid":1,"s_opushid":1,"s_appponetype":1,"s_headimageurl":1,"s_phone":1,"s_nickname":1,"s_appversion":1,"i_unlimited":1}`
|
|
|
data, ok := mongodb.FindOneByField("user", query, field)
|
|
|
if !ok {
|
|
|
return false
|
|
@@ -947,6 +940,7 @@ func createSession(s *httpsession.Session, person map[string]interface{}, loginI
|
|
|
s.Set("s_appponetype", person["s_appponetype"])
|
|
|
s.Set("s_appversion", person["s_appversion"])
|
|
|
s.Set("s_headimageurl", strings.Replace(qutil.ObjToString(person["s_headimageurl"]), "http://", "https://", 1))
|
|
|
+ s.Set("i_unlimited", qutil.IntAll(person["i_unlimited"]))
|
|
|
if qutil.ObjToString(person["s_phone"]) != "" {
|
|
|
phone := person["s_phone"].(string)
|
|
|
s.Set("s_phone", phone)
|
|
@@ -974,6 +968,17 @@ func createSession(s *httpsession.Session, person map[string]interface{}, loginI
|
|
|
Expires: expires,
|
|
|
}
|
|
|
http.SetCookie(rw, c)
|
|
|
+ //多账号登陆用户
|
|
|
+ i_unlimited := qutil.IntAll(person["i_unlimited"])
|
|
|
+ if i_unlimited > 0 {
|
|
|
+ uid := BsonIdToSId(person["_id"])
|
|
|
+ jy.PutLoginSess(mongodb, qutil.ObjToString(config.Sysconfig["appPushServiceRpc"]), fmt.Sprint(s.Id()), uid, qutil.IntAll(config.Sysconfig["criticality"]), i_unlimited)
|
|
|
+ redis.Put("other", fmt.Sprintf("app_%s", fmt.Sprint(s.Id())), &jy.AppLoginPush{
|
|
|
+ JgPushId: qutil.ObjToString(person["s_jpushid"]),
|
|
|
+ OtherPushId: qutil.ObjToString(person["s_opushid"]),
|
|
|
+ PhoneType: qutil.ObjToString(person["s_appponetype"]),
|
|
|
+ }, 86400*30)
|
|
|
+ }
|
|
|
return true
|
|
|
}
|
|
|
|
|
@@ -1003,11 +1008,11 @@ func ClearSession(s *httpsession.Session) {
|
|
|
s.Del("phoneAuthTime")
|
|
|
s.Del("mailAuthTime")
|
|
|
s.Del("phone")
|
|
|
-
|
|
|
+ s.Del("i_unlimited")
|
|
|
}
|
|
|
|
|
|
//生成签名,返回手机端
|
|
|
-func createSign(userid, rid, signType string) string {
|
|
|
+func createSign(userid, rid, signType string, session *httpsession.Session) string {
|
|
|
u := &UserSign{
|
|
|
UserId: userid,
|
|
|
CreateTime: time.Now().Unix(),
|
|
@@ -1033,14 +1038,22 @@ func getSign(u *UserSign) (string, string) {
|
|
|
|
|
|
//
|
|
|
func afterLogin(user map[string]interface{}, session *httpsession.Session, rid, oid, phoneType, channel, deviceId string, isNewUser bool, rw http.ResponseWriter) string {
|
|
|
+ log.Println("===>", fmt.Sprint(session.Id()))
|
|
|
userid := BsonIdToSId(user["_id"])
|
|
|
old_rid, _ := user["s_jpushid"].(string)
|
|
|
old_oid, _ := user["s_opushid"].(string)
|
|
|
old_ponetype, _ := user["s_appponetype"].(string)
|
|
|
+ off := true
|
|
|
go func() {
|
|
|
if !isNewUser {
|
|
|
+ if rd, ok := mongodb.FindById("user", userid, `{"i_unlimited":1}`); ok && rd != nil && len(*rd) > 0 {
|
|
|
+ i_unlimited := qutil.IntAll((*rd)["i_unlimited"])
|
|
|
+ if i_unlimited > 0 {
|
|
|
+ off = false
|
|
|
+ }
|
|
|
+ }
|
|
|
//同一账号在不同设备登录,极光id不一样,给之前的设备推送自定义的下线消息,离线消息保持10天
|
|
|
- if old_rid != "" && old_rid != rid {
|
|
|
+ if old_rid != "" && old_rid != rid && off {
|
|
|
mongodb.UpdateById("user", userid, map[string]interface{}{
|
|
|
"$addToSet": map[string]interface{}{"a_jpushid": old_rid},
|
|
|
})
|
|
@@ -1115,7 +1128,7 @@ func afterLogin(user map[string]interface{}, session *httpsession.Session, rid,
|
|
|
user["s_opushid"] = oid
|
|
|
user["s_appponetype"] = phoneType
|
|
|
createSession(session, user, "", 0, rw)
|
|
|
- return createSign(userid, rid, "登录后")
|
|
|
+ return createSign(userid, rid, "登录后", session)
|
|
|
}
|
|
|
|
|
|
//清空这个rid
|
|
@@ -1151,6 +1164,16 @@ func autoLogin(sign, from string, session *httpsession.Session, rw http.Response
|
|
|
if fromIsRestart && checkIsKicked(true, u.UserId, u.Rid, session) {
|
|
|
return -3
|
|
|
}
|
|
|
+ // //解析签名时 查看该签名是否被标记下线 如果被标记 则退出
|
|
|
+ // signKey := fmt.Sprintf("app_%s", fmt.Sprint(session.Id()))
|
|
|
+ // log.Println("key:", signKey)
|
|
|
+ // if data := redis.Get("other", signKey); data != nil {
|
|
|
+ // rdata := qutil.ObjToMap(data)
|
|
|
+ // ok, _ := (*rdata)["ok"].(bool)
|
|
|
+ // if sign == qutil.ObjToString((*rdata)["sign"]) && !ok {
|
|
|
+ // return -3
|
|
|
+ // }
|
|
|
+ // }
|
|
|
if createSession(session, nil, u.UserId, 0, rw) {
|
|
|
return 1
|
|
|
}
|