Skip to content

Commit 5655c94

Browse files
rajat1saxenaRajat
andcommitted
Entities deletion and media cleanup (#664)
* Communities data is cleaned up on delete * Product cleanup fixed * User and Community deletion; Card based UI for edit user and profile screens; * Fixed test cases * CodeQL fixes * Added tests around deleting product * CodeQL fixes --------- Co-authored-by: Rajat <hi@rajatsaxena.dev>
1 parent cb3f0bf commit 5655c94

File tree

70 files changed

+7574
-1022
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+7574
-1022
lines changed

.cursor/rules/basics.mdc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ alwaysApply: true
77
- Command for running script in a workspace: `pnpm --filter <workspace> <command>`.
88
- Command for running tests: `pnpm test`.
99
- The project uses shadcn for building UI so stick to its conventions and design.
10-
- In `apps/web` workspace, create a string first in `apps/web/config/strings.ts` and then import it in the `.tsx` files, instead of using inline strings.
10+
- In `apps/web` workspace, create a string first in `apps/web/config/strings.ts` and then import it in the `.tsx` files, instead of using inline strings.
11+
- When working with forms, always use refs to keep the current state of the form's data and use it to enable/disable the form submit button.
89.8 KB
Loading
159 KB
Loading

apps/docs/src/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export const SIDEBAR: Sidebar = {
7979
text: "Unlock additional products",
8080
link: "en/communities/grant-access-to-additional-products",
8181
},
82+
{ text: "Delete a community", link: "en/communities/delete" },
8283
],
8384
"Email marketing and automation": [
8485
{ text: "Introduction", link: "en/email-marketing/introduction" },
@@ -122,6 +123,7 @@ export const SIDEBAR: Sidebar = {
122123
{ text: "User permissions", link: "en/users/permissions" },
123124
{ text: "Filter users", link: "en/users/filters" },
124125
{ text: "Segment users", link: "en/users/segments" },
126+
{ text: "Delete a user", link: "en/users/delete" },
125127
],
126128
Developers: [
127129
{ text: "Introduction", link: "en/developers/introduction" },
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
---
2+
title: Delete a Community
3+
description: Guide to safely deleting communities and all associated data
4+
layout: ../../../layouts/MainLayout.astro
5+
---
6+
7+
Deleting a community is a permanent operation that removes the community and all its associated data from your school. This includes all posts, comments, members, and payment plans.
8+
9+
> **Important**: Community deletion is permanent and cannot be undone. All community content, memberships, and payment plans will be permanently removed.
10+
11+
## How Community Deletion Works
12+
13+
When you delete a community, CourseLit performs a comprehensive cleanup:
14+
15+
1. **Content Deletion**: Removes all posts, comments, and reports
16+
2. **Membership Cleanup**: Cancels all memberships and payment plans
17+
3. **Page Removal**: Deletes the community's public page
18+
4. **Media Cleanup**: Removes all associated media files
19+
5. **Community Document**: Deletes the community itself
20+
21+
## Prerequisites
22+
23+
To delete a community, you must have the `Manage Community` permission.
24+
25+
> **Note**: Even community moderators cannot delete a community. Only users with the `Manage Community` permission (typically site admins) can perform this operation.
26+
27+
## Deleting a Community
28+
29+
1. Navigate to the **Communities** area from your admin dashboard
30+
2. Select the community you want to delete
31+
3. Click on **Manage** to open settings
32+
4. Scroll down to the Danger zone and click on **Delete Community** button
33+
34+
![Delete community](/assets/communities/delete-community.png)
35+
36+
5. Confirm the deletion when prompted
37+
38+
## What Gets Deleted
39+
40+
### Community Content
41+
42+
All content within the community is permanently removed:
43+
44+
- **Posts**: All posts created in the community
45+
- **Comments**: All comments on posts, including nested replies
46+
- **Reports**: All content reports filed by members
47+
- **Media**: All images, videos, and files uploaded to posts (when media uploads are enabled)
48+
49+
### Memberships & Subscriptions
50+
51+
All membership-related data is removed:
52+
53+
- **Community Memberships**: All member records for the community
54+
- **Payment Subscriptions**: All active subscriptions are automatically cancelled
55+
- **Payment Plans**: All payment plans associated with the community
56+
- **Included Product Memberships**: If the community's payment plans included access to courses, those memberships are also removed
57+
- **Post Subscriptions**: All user subscriptions to community posts
58+
59+
### Community Infrastructure
60+
61+
The community's infrastructure is removed:
62+
63+
- **Community Page**: The public-facing community page
64+
- **Community Settings**: All configuration and settings
65+
- **Categories**: All community categories
66+
- **Featured Images**: Community banner and featured images
67+
68+
### Related Data
69+
70+
Additional data associated with the community:
71+
72+
- **Activities**: Activity logs related to payment plan enrollments
73+
- **Notifications**: Notifications related to the community (for members)
74+
75+
## What Happens to Members
76+
77+
When a community is deleted:
78+
79+
1. **Active Subscriptions**: All payment subscriptions are automatically cancelled through your payment provider (Stripe, PayPal, etc.)
80+
2. **Membership Records**: All membership records are permanently deleted
81+
3. **Access Revoked**: Members immediately lose access to the community
82+
4. **Included Products**: If members had access to courses through the community's payment plan, that access is also revoked
83+
84+
## Payment Plan Considerations
85+
86+
### Subscription Cancellations
87+
88+
- All active subscriptions are cancelled automatically
89+
- Payment providers (Stripe, PayPal, etc.) are notified
90+
- No further charges will occur
91+
- Members will not receive refunds automatically
92+
93+
### Included Products
94+
95+
If your community's payment plans [included access to courses](/en/communities/grant-access-to-additional-products) or other products:
96+
97+
- All memberships to those products (activated through the community plan) are removed
98+
- Activity logs for those memberships are deleted
99+
- Direct purchases of those products (not through the community) are not affected
100+
101+
## Media Cleanup
102+
103+
The deletion process handles media files appropriately:
104+
105+
- **Community Images**: Featured images and banners are deleted
106+
- **Post Media**: When media uploads are enabled, all media from posts is deleted
107+
- **User Avatars**: Not affected (user avatars are tied to user accounts, not communities)
108+
109+
> **Note**: Currently, media uploads in community posts are not enabled. When this feature is activated, the deletion process will handle post media cleanup automatically.
110+
111+
## Safety Measures
112+
113+
CourseLit implements safety measures to ensure proper deletion:
114+
115+
1. **Permission Check**: Only users with `Manage Community` permission can delete
116+
2. **Confirmation Required**: Deletion requires explicit confirmation
117+
3. **Atomic Operation**: The entire deletion succeeds or fails as a unit
118+
4. **Subscription Cancellation**: Automatic cancellation prevents future charges
119+
120+
## Before Deleting a Community
121+
122+
Consider these steps before deleting:
123+
124+
1. **Notify Members**: Inform community members about the upcoming deletion
125+
2. **Export Data**: If you need to preserve any content, export it manually. Only works for self-hosted installations.
126+
3. **Handle Refunds**: Process any necessary refunds through your payment provider
127+
4. **Alternative Actions**: Consider making the community private instead of deleting it
128+
129+
## After Deletion
130+
131+
After a community is deleted:
132+
133+
- The community page returns a 404 error
134+
- Members cannot access the community anymore
135+
- All content is permanently lost
136+
- Payment subscriptions are cancelled
137+
- The community name becomes available for reuse
138+
139+
## Handling Refunds
140+
141+
Community deletion does not automatically issue refunds. To handle refunds:
142+
143+
1. **Before Deletion**: Note all active subscriptions and their subscription IDs
144+
2. **Access Payment Provider**: Log into your Stripe, PayPal, or other payment provider dashboard
145+
3. **Process Refunds**: Manually issue refunds as appropriate
146+
4. **Delete Community**: Once refunds are processed, proceed with deletion
147+
148+
## Alternative to Deletion
149+
150+
If you want to preserve content but stop new members from joining:
151+
152+
1. **Disable the Community**: Toggle the community to "disabled" in settings
153+
2. **Remove Payment Plans**: Archive all payment plans
154+
155+
This approach preserves content while preventing new access.
156+
157+
## Troubleshooting
158+
159+
### Cannot Delete Community
160+
161+
If you encounter errors:
162+
163+
- **"Action not allowed"**: You don't have the `Manage Community` permission
164+
- **"Item not found"**: The community may have already been deleted or doesn't exist
165+
- **"Community not found"**: You may not have access to this community
166+
167+
### Subscription Cancellation Issues
168+
169+
If subscriptions fail to cancel:
170+
171+
1. Manually cancel subscriptions in your payment provider's dashboard
172+
2. Contact support if issues persist
173+
174+
### Partial Deletion
175+
176+
If deletion fails partway through:
177+
178+
- The operation is designed to be atomic, but in rare cases, partial deletion may occur
179+
- Contact support with error details
180+
- Manual cleanup may be required
181+
182+
## Best Practices
183+
184+
1. **Communicate Early**: Give members advance notice before deletion
185+
2. **Export Important Content**: Save any valuable discussions or content
186+
3. **Process Refunds First**: Handle refunds before deleting to maintain records
187+
4. **Document the Decision**: Keep records of why and when the community was deleted
188+
5. **Consider Alternatives**: Evaluate if disabling is sufficient instead of deletion
189+
190+
## GDPR and Data Protection
191+
192+
Community deletion helps with data protection compliance:
193+
194+
- All member data within the community is removed
195+
- Personal information in posts and comments is deleted
196+
- Membership records are permanently erased
197+
- The operation can be part of a broader data cleanup strategy
198+
199+
## Stuck somewhere?
200+
201+
We are always here for you. Come chat with us in our <a href="https://discord.com/invite/GR4bQsN" target="_blank">Discord</a> channel or send a tweet at <a href="https://twitter.com/courselit" target="_blank">@CourseLit</a>.
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
---
2+
title: Delete a User
3+
description: Guide to safely deleting users with GDPR compliance
4+
layout: ../../../layouts/MainLayout.astro
5+
---
6+
7+
Deleting a user is a critical operation that removes all personal data associated with that user from your school. This feature is designed to comply with GDPR and other data protection regulations.
8+
9+
> **Important**: User deletion is permanent and cannot be undone. All personal data will be removed, and business entities will be transferred to the admin performing the deletion.
10+
11+
## How User Deletion Works
12+
13+
When you delete a user, CourseLit performs two main operations:
14+
15+
1. **Business Entity Migration**: Transfers ownership of courses, communities, email templates, and other business-critical resources to the admin performing the deletion
16+
2. **Personal Data Cleanup**: Permanently removes all personal data associated with the user
17+
18+
## Prerequisites
19+
20+
To delete a user, you must have the `Manage Users` permission. Additionally:
21+
22+
- You cannot delete yourself
23+
- You cannot delete the last user with critical permissions (like `Manage Site`, `Manage Users`, etc.)
24+
- The system ensures at least one admin remains with each critical permission
25+
26+
## Deleting a User
27+
28+
1. Navigate to the **Users** area from the dashboard
29+
2. Click on the user you want to delete to open their details
30+
3. Scroll down to the Danger zone and click on **Delete user** button
31+
32+
![Delete user](/assets/users/delete-user.png)
33+
34+
4. Confirm the deletion when prompted
35+
36+
## What Gets Migrated
37+
38+
The following business entities are transferred to the admin performing the deletion:
39+
40+
### Courses & Content
41+
42+
- **Course Ownership**: All courses created by the user
43+
- **Lesson Ownership**: All lessons created by the user
44+
- **Page Ownership**: All pages created by the user (course pages, blog pages, etc.)
45+
46+
### Communities
47+
48+
- **Community Ownership**: All communities created by the user
49+
- **Community Posts**: All posts created by the user in any community
50+
- **Community Comments**: All comments made by the user
51+
52+
### Email Marketing
53+
54+
- **Email Templates**: All email templates created by the user
55+
- **Email Sequences**: All email sequences (campaigns) created by the user
56+
- **Broadcasts**: All email broadcasts created by the user
57+
58+
### Other Business Entities
59+
60+
- **Payment Plans**: All payment plans created by the user
61+
- **User Themes**: All custom themes created by the user
62+
- **User Segments**: All user segments created by the user
63+
64+
## What Gets Deleted
65+
66+
The following personal data is permanently removed:
67+
68+
### User Account & Profile
69+
70+
- User account and profile information
71+
- User avatar and media files
72+
- Authentication tokens and sessions
73+
74+
### Activity & Engagement
75+
76+
- Course enrollments and memberships
77+
- Lesson progress and evaluations
78+
- Download links generated for the user
79+
- Activity logs and analytics data
80+
- Notifications sent to the user
81+
82+
### Community Participation
83+
84+
- Community membership records
85+
- Community post subscriptions
86+
- Community reports filed by the user
87+
88+
### Email & Communications
89+
90+
- Email delivery records
91+
- Email event logs (opens, clicks, etc.)
92+
- Ongoing email sequences for the user
93+
- Mail request status records
94+
95+
### Financial Records
96+
97+
- Invoices associated with the user
98+
- Payment subscriptions (cancelled automatically)
99+
100+
### Certificates
101+
102+
- Certificates issued to the user
103+
104+
## GDPR Compliance
105+
106+
This deletion process is designed to comply with GDPR Article 17 (Right to Erasure). When a user is deleted:
107+
108+
- All personal data is permanently removed
109+
- Business entities are preserved to maintain system integrity
110+
- The operation is logged for audit purposes
111+
- Payment subscriptions are automatically cancelled
112+
113+
## Safety Measures
114+
115+
CourseLit implements several safety measures to prevent accidental data loss:
116+
117+
1. **Permission Validation**: Ensures at least one user retains each critical permission
118+
2. **Self-Deletion Prevention**: You cannot delete your own account
119+
3. **Confirmation Required**: Deletion requires explicit confirmation
120+
4. **Atomic Operation**: The entire deletion process succeeds or fails as a unit
121+
122+
## After Deletion
123+
124+
After a user is deleted:
125+
126+
- All their business entities (courses, communities, etc.) continue to function normally under the new owner
127+
- Students enrolled in their courses can continue learning
128+
- Community members can continue participating
129+
- Email sequences continue running for other users
130+
- The deleted user cannot log in anymore
131+
132+
## Handling Subscription Cancellations
133+
134+
If the deleted user had active payment subscriptions:
135+
136+
- All subscriptions are automatically cancelled
137+
- The payment provider (Stripe, PayPal, etc.) is notified
138+
- No further charges will occur
139+
- Refunds must be handled manually through your payment provider if needed
140+
141+
## Best Practices
142+
143+
1. **Review Before Deletion**: Check what content and entities the user owns before deleting
144+
2. **Notify Stakeholders**: If the user created important courses or communities, inform relevant team members
145+
3. **Export Data First**: If you need to retain any information for records, export it before deletion
146+
4. **Handle Refunds**: Process any necessary refunds through your payment provider before deletion
147+
5. **Document the Action**: Keep a record of why and when the user was deleted for compliance purposes
148+
149+
## Troubleshooting
150+
151+
### Cannot Delete User
152+
153+
If you encounter an error when trying to delete a user:
154+
155+
- **"Cannot delete last user with permission X"**: This user is the last one with a critical permission. Assign this permission to another user first.
156+
- **"Action not allowed"**: You don't have the `Manage Users` permission.
157+
- **"User not found"**: The user may have already been deleted or doesn't exist.
158+
159+
### Subscription Cancellation Failed
160+
161+
If a subscription fails to cancel:
162+
163+
1. Note the subscription ID from the error message
164+
2. Manually cancel the subscription in your payment provider's dashboard
165+
3. Try the deletion again
166+
167+
## Stuck somewhere?
168+
169+
We are always here for you. Come chat with us in our <a href="https://discord.com/invite/GR4bQsN" target="_blank">Discord</a> channel or send a tweet at <a href="https://twitter.com/courselit" target="_blank">@CourseLit</a>.

0 commit comments

Comments
 (0)