Users: Allow specifying user UIDs in params (#95424)
* add user ID API translation * add uid to user frontend * use users' UIDs in admin pages * fix ldapSync page * use global user search for user by UID * remove active org filtering * remove orgID params
This commit is contained in:
@@ -2,6 +2,7 @@ package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/grafana/grafana/pkg/registry"
|
||||
)
|
||||
@@ -13,6 +14,7 @@ type Service interface {
|
||||
CreateServiceAccount(context.Context, *CreateUserCommand) (*User, error)
|
||||
Delete(context.Context, *DeleteUserCommand) error
|
||||
GetByID(context.Context, *GetUserByIDQuery) (*User, error)
|
||||
// GetByUID returns a user by UID. This also includes service accounts (identity use only)
|
||||
GetByUID(context.Context, *GetUserByUIDQuery) (*User, error)
|
||||
GetByLogin(context.Context, *GetUserByLoginQuery) (*User, error)
|
||||
GetByEmail(context.Context, *GetUserByEmailQuery) (*User, error)
|
||||
@@ -28,3 +30,16 @@ type Verifier interface {
|
||||
Start(ctx context.Context, cmd StartVerifyEmailCommand) error
|
||||
Complete(ctx context.Context, cmd CompleteEmailVerifyCommand) error
|
||||
}
|
||||
|
||||
func UIDToIDHandler(userService Service) func(ctx context.Context, userID string) (string, error) {
|
||||
return func(ctx context.Context, userID string) (string, error) {
|
||||
_, err := strconv.ParseInt(userID, 10, 64)
|
||||
if userID == "" || err == nil {
|
||||
return userID, nil
|
||||
}
|
||||
user, err := userService.GetByUID(ctx, &GetUserByUIDQuery{
|
||||
UID: userID,
|
||||
})
|
||||
return strconv.FormatInt(user.ID, 10), err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user