From 8c96c62a7c57f00f1b504ac838cd00f2825943bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 22 Apr 2020 11:55:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=88=A4=E6=96=AD=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=B2=A1=E6=9C=89?= =?UTF-8?q?openid=E5=B0=B1=E5=81=9A=E6=A0=87=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/auth2/auth2.go | 15 +++++++++++++++ business/auth2/auth_info.go | 9 +++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/business/auth2/auth2.go b/business/auth2/auth2.go index 0699af181..a120a1246 100644 --- a/business/auth2/auth2.go +++ b/business/auth2/auth2.go @@ -274,6 +274,21 @@ func LoginInternal(ctx *Context, authType, authID, authIDType, authSecret string if user != nil && user.GetID() != "" { userProvider.UpdateLastLogin(user.GetID(), authType, ctx.GetRealRemoteIP()) } + //如果是小程序 + if authType == "weixinmini" { + appID := strings.Split(authSecret, ",")[0] + if appID == "wx08a5c2a8581414ff" || appID == "wx2d6949f724b2541d" { //菜市或者果园 + binds, err := dao.GetUserBindAuthInfo(dao.GetDB(), user.GetID(), 0, nil, "", "", "weixinsns") + if err != nil { + return authInfo, err + } + if len(binds) == 0 { + authInfo.IsExistOpenID = false + } else { + authInfo.IsExistOpenID = true + } + } + } } } else { err = ErrIllegalAuthType diff --git a/business/auth2/auth_info.go b/business/auth2/auth_info.go index 7ca58252d..2cf07072d 100644 --- a/business/auth2/auth_info.go +++ b/business/auth2/auth_info.go @@ -69,10 +69,11 @@ type AuthInfo struct { UserBasic // 登录成功后保存的用户信息 AuthBindInfo *AuthBindEx `json:"authBindInfo"` - LoginTime time.Time `json:"loginTime"` - ExpiresAt int64 `json:"expiresAt"` - Token string `json:"token"` - TokenType int `json:"tokenType"` // TOKEN类型, + LoginTime time.Time `json:"loginTime"` + ExpiresAt int64 `json:"expiresAt"` + Token string `json:"token"` + TokenType int `json:"tokenType"` // TOKEN类型, + IsExistOpenID bool `json:"isExistOpenID"` } func (a *AuthInfo) GetAuthID() string {