grafana/pkg/services/user/user.go
Oleg Gaidarenko 35f227de11
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
2019-05-17 14:57:26 +03:00

40 lines
802 B
Go

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
}