@@ -290,43 +290,6 @@ func (uc *OrganizationUseCase) Delete(ctx context.Context, id string) error {
290290 return uc .orgRepo .Delete (ctx , orgUUID )
291291}
292292
293- // DeleteByUser deletes an organization initiated by a user with owner validation
294- // Only organization owners can delete an organization
295- func (uc * OrganizationUseCase ) DeleteByUser (ctx context.Context , orgName , userID string ) error {
296- // Find organization by name
297- org , err := uc .orgRepo .FindByName (ctx , orgName )
298- if err != nil {
299- return err
300- } else if org == nil {
301- return NewErrNotFound ("organization" )
302- }
303-
304- orgUUID , err := uuid .Parse (org .ID )
305- if err != nil {
306- return NewErrInvalidUUID (err )
307- }
308-
309- userUUID , err := uuid .Parse (userID )
310- if err != nil {
311- return NewErrInvalidUUID (err )
312- }
313-
314- // Check if user is an owner of the organization
315- m , err := uc .membershipRepo .FindByOrgAndUser (ctx , orgUUID , userUUID )
316- if err != nil {
317- return fmt .Errorf ("failed to find owners: %w" , err )
318- }
319-
320- if m == nil || m .Role != authz .RoleOwner {
321- return NewErrValidationStr ("only organization owners can delete the organization" )
322- }
323-
324- uc .logger .Infow ("msg" , "User deleting organization" , "user_id" , userID , "organization_id" , org .ID )
325-
326- // Use the existing Delete method to handle the actual deletion
327- return uc .Delete (ctx , org .ID )
328- }
329-
330293// AutoOnboardOrganizations creates the organizations specified in the onboarding config and assigns the user to them
331294// with the specified role if they are not already a member.
332295func (uc * OrganizationUseCase ) AutoOnboardOrganizations (ctx context.Context , userID string ) error {
0 commit comments