feat: fix search for ldap users' name within an organization (#2476)

* fix: #2304

* fix: when logging in with OAuth2 and authenticating via WebAuthn, retrieve the application from the clientId.

* fix: search for ldap users' name within an organization

---------

Co-authored-by: aidenlu <aiden_lu@wochacha.com>
This commit is contained in:
aiden 2023-11-05 21:48:23 -06:00 committed by GitHub
parent 53c89bbe89
commit 6c69daa666
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -305,7 +305,7 @@ func SyncLdapUsers(owner string, syncUsers []LdapUser, ldapId string) (existUser
return nil, nil, err
}
name, err := syncUser.buildLdapUserName()
name, err := syncUser.buildLdapUserName(owner)
if err != nil {
return nil, nil, err
}
@ -354,10 +354,10 @@ func GetExistUuids(owner string, uuids []string) ([]string, error) {
return existUuids, nil
}
func (ldapUser *LdapUser) buildLdapUserName() (string, error) {
func (ldapUser *LdapUser) buildLdapUserName(owner string) (string, error) {
user := User{}
uidWithNumber := fmt.Sprintf("%s_%s", ldapUser.Uid, ldapUser.UidNumber)
has, err := ormer.Engine.Where("name = ? or name = ?", ldapUser.Uid, uidWithNumber).Get(&user)
has, err := ormer.Engine.Where("owner = ? and (name = ? or name = ?)", owner, ldapUser.Uid, uidWithNumber).Get(&user)
if err != nil {
return "", err
}