fix: send user and login in registration response

This commit is contained in:
Johan Siebens
2022-12-21 06:12:41 +01:00
parent b2dbe3b9c5
commit a8e8d1aa49
8 changed files with 78 additions and 5 deletions
+5 -1
View File
@@ -47,7 +47,7 @@ func (s *Service) DeleteUser(ctx context.Context, req *connect.Request[api.Delet
principal := CurrentPrincipal(ctx)
if !principal.IsSystemAdmin() && principal.UserMatches(req.Msg.UserId) {
return nil, connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("unable delete yourself"))
return nil, connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("unable to delete yourself"))
}
user, err := s.repository.GetUser(ctx, req.Msg.UserId)
@@ -63,6 +63,10 @@ func (s *Service) DeleteUser(ctx context.Context, req *connect.Request[api.Delet
return nil, connect.NewError(connect.CodePermissionDenied, fmt.Errorf("permission denied"))
}
if user.UserType == domain.UserTypeService {
return nil, connect.NewError(connect.CodeInvalidArgument, fmt.Errorf("unable delete service account"))
}
err = s.repository.Transaction(func(tx domain.Repository) error {
if err := tx.DeleteMachineByUser(ctx, req.Msg.UserId); err != nil {
return err