mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* 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
40 lines
802 B
Go
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
|
|
}
|