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:
Jo
2024-10-30 14:14:42 +01:00
committed by GitHub
parent f0391e31d2
commit 90d2f4659e
23 changed files with 175 additions and 93 deletions
+15
View File
@@ -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
}
}