MM-12488: Accepts parameters to search and filter LDAP groups. (#10418)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
e94faea383
Коммит
5dbf8aec7d
12
api4/ldap.go
12
api4/ldap.go
@@ -68,7 +68,17 @@ func getLdapGroups(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
groups, total, err := c.App.GetAllLdapGroupsPage(c.Params.Page, c.Params.PerPage)
|
opts := model.GroupSearchOpts{
|
||||||
|
Q: c.Params.Q,
|
||||||
|
}
|
||||||
|
if c.Params.IsLinked != nil {
|
||||||
|
opts.IsLinked = c.Params.IsLinked
|
||||||
|
}
|
||||||
|
if c.Params.IsConfigured != nil {
|
||||||
|
opts.IsConfigured = c.Params.IsConfigured
|
||||||
|
}
|
||||||
|
|
||||||
|
groups, total, err := c.App.GetAllLdapGroupsPage(c.Params.Page, c.Params.PerPage, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Err = err
|
c.Err = err
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -61,13 +61,13 @@ func (a *App) GetLdapGroup(ldapGroupID string) (*model.Group, *model.AppError) {
|
|||||||
|
|
||||||
// GetAllLdapGroupsPage retrieves all LDAP groups under the configured base DN using the default or configured group
|
// GetAllLdapGroupsPage retrieves all LDAP groups under the configured base DN using the default or configured group
|
||||||
// filter.
|
// filter.
|
||||||
func (a *App) GetAllLdapGroupsPage(page int, perPage int) ([]*model.Group, int, *model.AppError) {
|
func (a *App) GetAllLdapGroupsPage(page int, perPage int, opts model.GroupSearchOpts) ([]*model.Group, int, *model.AppError) {
|
||||||
var groups []*model.Group
|
var groups []*model.Group
|
||||||
var total int
|
var total int
|
||||||
|
|
||||||
if a.Ldap != nil {
|
if a.Ldap != nil {
|
||||||
var err *model.AppError
|
var err *model.AppError
|
||||||
groups, total, err = a.Ldap.GetAllGroupsPage(page, perPage)
|
groups, total, err = a.Ldap.GetAllGroupsPage(page, perPage, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,6 @@ type LdapInterface interface {
|
|||||||
GetAllLdapUsers() ([]*model.User, *model.AppError)
|
GetAllLdapUsers() ([]*model.User, *model.AppError)
|
||||||
MigrateIDAttribute(toAttribute string) error
|
MigrateIDAttribute(toAttribute string) error
|
||||||
GetGroup(groupUID string) (*model.Group, *model.AppError)
|
GetGroup(groupUID string) (*model.Group, *model.AppError)
|
||||||
GetAllGroupsPage(page int, perPage int) ([]*model.Group, int, *model.AppError)
|
GetAllGroupsPage(page int, perPage int, opts model.GroupSearchOpts) ([]*model.Group, int, *model.AppError)
|
||||||
FirstLoginSync(userID, userAuthService, userAuthData string) *model.AppError
|
FirstLoginSync(userID, userAuthService, userAuthData string) *model.AppError
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,12 @@ type GroupPatch struct {
|
|||||||
Description *string `json:"description"`
|
Description *string `json:"description"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GroupSearchOpts struct {
|
||||||
|
Q string
|
||||||
|
IsLinked *bool
|
||||||
|
IsConfigured *bool
|
||||||
|
}
|
||||||
|
|
||||||
func (group *Group) Patch(patch *GroupPatch) {
|
func (group *Group) Patch(patch *GroupPatch) {
|
||||||
if patch.Name != nil {
|
if patch.Name != nil {
|
||||||
group.Name = *patch.Name
|
group.Name = *patch.Name
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ type Params struct {
|
|||||||
SyncableId string
|
SyncableId string
|
||||||
SyncableType model.GroupSyncableType
|
SyncableType model.GroupSyncableType
|
||||||
BotUserId string
|
BotUserId string
|
||||||
|
Q string
|
||||||
|
IsLinked *bool
|
||||||
|
IsConfigured *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParamsFromRequest(r *http.Request) *Params {
|
func ParamsFromRequest(r *http.Request) *Params {
|
||||||
@@ -232,5 +235,15 @@ func ParamsFromRequest(r *http.Request) *Params {
|
|||||||
params.BotUserId = val
|
params.BotUserId = val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
params.Q = query.Get("q")
|
||||||
|
|
||||||
|
if val, err := strconv.ParseBool(query.Get("is_linked")); err == nil {
|
||||||
|
params.IsLinked = &val
|
||||||
|
}
|
||||||
|
|
||||||
|
if val, err := strconv.ParseBool(query.Get("is_configured")); err == nil {
|
||||||
|
params.IsConfigured = &val
|
||||||
|
}
|
||||||
|
|
||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user