Feature: LDAP refactoring (#16950)
* incapsulates multipleldap logic under one module * abstracts users upsert and get logic * changes some of the text error messages and import sort sequence * heavily refactors the LDAP module – LDAP module now only deals with LDAP related behaviour * integrates affected auth_proxy module and their tests * refactoring of the auth_proxy logic
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
)
|
||||
|
||||
// UpsertArgs are object for Upsert method
|
||||
type UpsertArgs struct {
|
||||
ReqContext *models.ReqContext
|
||||
ExternalUser *models.ExternalUserInfo
|
||||
SignupAllowed bool
|
||||
}
|
||||
|
||||
// Upsert add/update grafana user
|
||||
func Upsert(args *UpsertArgs) (*models.User, error) {
|
||||
query := &models.UpsertUserCommand{
|
||||
ReqContext: args.ReqContext,
|
||||
ExternalUser: args.ExternalUser,
|
||||
SignupAllowed: args.SignupAllowed,
|
||||
}
|
||||
err := bus.Dispatch(query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return query.Result, nil
|
||||
}
|
||||
|
||||
// Get the users
|
||||
func Get(
|
||||
query *models.SearchUsersQuery,
|
||||
) ([]*models.UserSearchHitDTO, error) {
|
||||
if err := bus.Dispatch(query); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return query.Result.Users, nil
|
||||
}
|
||||
Reference in New Issue
Block a user