Remove delete suer from store interface (#53726)

This commit is contained in:
idafurjes 2022-08-15 13:56:16 +02:00 committed by GitHub
parent 1c0ab501aa
commit dfc75b1114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 9 deletions

View File

@ -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)
}

View File

@ -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)

View File

@ -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
}

View File

@ -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)