mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-09 21:12:56 +08:00
feat: add owner to getUserByWechatId()
This commit is contained in:
@@ -794,7 +794,7 @@ func GetWechatMiniProgramToken(application *Application, code string, host strin
|
|||||||
ErrorDescription: "the wechat mini program session is invalid",
|
ErrorDescription: "the wechat mini program session is invalid",
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
user, err := getUserByWechatId(openId, unionId)
|
user, err := getUserByWechatId(application.Organization, openId, unionId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@@ -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 == "" {
|
if wechatUnionId == "" {
|
||||||
wechatUnionId = wechatOpenId
|
wechatUnionId = wechatOpenId
|
||||||
}
|
}
|
||||||
user := &User{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user