Support LDAP search by user tag

This commit is contained in:
Yang Luo
2023-05-12 13:03:43 +08:00
parent c33d537ac1
commit 96a3db21a1
4 changed files with 52 additions and 3 deletions

View File

@ -282,6 +282,10 @@ func CheckUserPermission(requestUserId, userId string, strict bool, lang string)
if userId != "" {
targetUser := GetUser(userId)
if targetUser == nil {
if strings.HasPrefix(requestUserId, "built-in/") {
return true, nil
}
return false, fmt.Errorf(i18n.Translate(lang, "general:The user: %s doesn't exist"), userId)
}

View File

@ -250,6 +250,16 @@ func GetUsers(owner string) []*User {
return users
}
func GetUsersByTag(owner string, tag string) []*User {
users := []*User{}
err := adapter.Engine.Desc("created_time").Find(&users, &User{Owner: owner, Tag: tag})
if err != nil {
panic(err)
}
return users
}
func GetSortedUsers(owner string, sorter string, limit int) []*User {
users := []*User{}
err := adapter.Engine.Desc(sorter).Limit(limit, 0).Find(&users, &User{Owner: owner})