Skip to content

Commit

Permalink
make sure unintended alias is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuZad committed Aug 24, 2023
1 parent c5d965a commit f41d02a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/provider/resource_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,23 @@ func resourceUserUpdate(ctx context.Context, d *schema.ResourceData, meta interf
return fmt.Errorf("timed out while waiting for %s to be updated", cc.resourceType)
})

if d.HasChange("primary_email") {
old, _ := d.GetChange("primary_email")
oldPrimary := old.(string)

// Remove old primary pleeeeease

aliasesService, diags := GetUserAliasService(usersService)
if diags.HasError() {
return diags
}

err := aliasesService.Delete(d.Id(), oldPrimary).Do()
if err != nil {
return diag.FromErr(err)
}
}

if err != nil {
return diag.FromErr(err)
}
Expand Down

0 comments on commit f41d02a

Please sign in to comment.