mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Remove delete suer from store interface (#53726)
This commit is contained in:
parent
1c0ab501aa
commit
dfc75b1114
@ -189,9 +189,9 @@ func (hs *HTTPServer) AdminDeleteUser(c *models.ReqContext) response.Response {
|
||||
return response.Error(http.StatusBadRequest, "id is invalid", err)
|
||||
}
|
||||
|
||||
cmd := models.DeleteUserCommand{UserId: userID}
|
||||
cmd := user.DeleteUserCommand{UserID: userID}
|
||||
|
||||
if err := hs.SQLStore.DeleteUser(c.Req.Context(), &cmd); err != nil {
|
||||
if err := hs.userService.Delete(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, user.ErrUserNotFound) {
|
||||
return response.Error(404, user.ErrUserNotFound.Error(), nil)
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ type ServiceAccountsStoreImpl struct {
|
||||
apiKeyService apikey.Service
|
||||
kvStore kvstore.KVStore
|
||||
log log.Logger
|
||||
userService user.Service
|
||||
}
|
||||
|
||||
func ProvideServiceAccountsStore(store *sqlstore.SQLStore, apiKeyService apikey.Service, kvStore kvstore.KVStore) *ServiceAccountsStoreImpl {
|
||||
@ -456,7 +457,7 @@ func (s *ServiceAccountsStoreImpl) CreateServiceAccountFromApikey(ctx context.Co
|
||||
}
|
||||
|
||||
if err := s.assignApiKeyToServiceAccount(sess, key.Id, newSA.ID); err != nil {
|
||||
if err := s.sqlStore.DeleteUser(ctx, &models.DeleteUserCommand{UserId: newSA.ID}); err != nil {
|
||||
if err := s.userService.Delete(ctx, &user.DeleteUserCommand{UserID: newSA.ID}); err != nil {
|
||||
s.log.Error("Error deleting service account", "error", err)
|
||||
}
|
||||
return fmt.Errorf("failed to migrate API key to service account token: %w", err)
|
||||
|
@ -170,11 +170,6 @@ func (m *SQLStoreMock) BatchDisableUsers(ctx context.Context, cmd *models.BatchD
|
||||
return m.ExpectedError
|
||||
}
|
||||
|
||||
func (m *SQLStoreMock) DeleteUser(ctx context.Context, cmd *models.DeleteUserCommand) error {
|
||||
m.LatestUserId = cmd.UserId
|
||||
return m.ExpectedError
|
||||
}
|
||||
|
||||
func (m *SQLStoreMock) UpdateUserPermissions(userID int64, isAdmin bool) error {
|
||||
return m.ExpectedError
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ type Store interface {
|
||||
SearchUsers(ctx context.Context, query *models.SearchUsersQuery) error
|
||||
DisableUser(ctx context.Context, cmd *models.DisableUserCommand) error
|
||||
BatchDisableUsers(ctx context.Context, cmd *models.BatchDisableUsersCommand) error
|
||||
DeleteUser(ctx context.Context, cmd *models.DeleteUserCommand) error
|
||||
UpdateUserPermissions(userID int64, isAdmin bool) error
|
||||
SetUserHelpFlag(ctx context.Context, cmd *models.SetUserHelpFlagCommand) error
|
||||
CreateTeam(name, email string, orgID int64) (models.Team, error)
|
||||
|
Loading…
Reference in New Issue
Block a user