feat: add owner to getUserByWechatId()

This commit is contained in:
Yang Luo 2023-06-21 20:54:19 +08:00
parent c391af4552
commit a3b0f1fc74
2 changed files with 3 additions and 3 deletions

View File

@ -794,7 +794,7 @@ func GetWechatMiniProgramToken(application *Application, code string, host strin
ErrorDescription: "the wechat mini program session is invalid",
}, nil
}
user, err := getUserByWechatId(openId, unionId)
user, err := getUserByWechatId(application.Organization, openId, unionId)
if err != nil {
return nil, nil, err
}

View File

@ -319,12 +319,12 @@ func getUserById(owner string, id string) (*User, error) {
}
}
func getUserByWechatId(wechatOpenId string, wechatUnionId string) (*User, error) {
func getUserByWechatId(owner string, wechatOpenId string, wechatUnionId string) (*User, error) {
if wechatUnionId == "" {
wechatUnionId = wechatOpenId
}
user := &User{}
existed, err := adapter.Engine.Where("wechat = ? OR wechat = ?", wechatOpenId, wechatUnionId).Get(user)
existed, err := adapter.Engine.Where("owner = ?", owner).Where("wechat = ? OR wechat = ?", wechatOpenId, wechatUnionId).Get(user)
if err != nil {
return nil, err
}