Implement account deletion handling and improve user feedback
Some checks failed
Chore App Build and Push Docker Images / build-and-push (push) Has been cancelled
Some checks failed
Chore App Build and Push Docker Images / build-and-push (push) Has been cancelled
- Added checks for accounts marked for deletion in signup, verification, and password reset processes. - Updated reward and task listing to sort user-created items first. - Enhanced user API to clear verification and reset tokens when marking accounts for deletion. - Introduced tests for marked accounts to ensure proper handling in various scenarios. - Updated profile and reward edit components to reflect changes in validation and data handling.
This commit is contained in:
@@ -210,11 +210,18 @@ def delete_user_data(user: User) -> bool:
|
||||
pass
|
||||
return False
|
||||
|
||||
def process_deletion_queue():
|
||||
def process_deletion_queue(force=False):
|
||||
"""
|
||||
Process the deletion queue: find users due for deletion and delete them.
|
||||
|
||||
Args:
|
||||
force (bool): If True, delete all marked users immediately without checking threshold.
|
||||
If False, only delete users past the threshold time.
|
||||
"""
|
||||
logger.info("Starting deletion scheduler run")
|
||||
if force:
|
||||
logger.info("Starting FORCED deletion scheduler run (bypassing time threshold)")
|
||||
else:
|
||||
logger.info("Starting deletion scheduler run")
|
||||
|
||||
processed = 0
|
||||
deleted = 0
|
||||
@@ -235,8 +242,8 @@ def process_deletion_queue():
|
||||
user = User.from_dict(user_dict)
|
||||
processed += 1
|
||||
|
||||
# Check if user is due for deletion
|
||||
if not is_user_due_for_deletion(user):
|
||||
# Check if user is due for deletion (skip check if force=True)
|
||||
if not force and not is_user_due_for_deletion(user):
|
||||
continue
|
||||
|
||||
# Check retry limit
|
||||
@@ -346,10 +353,11 @@ def stop_deletion_scheduler():
|
||||
def trigger_deletion_manually():
|
||||
"""
|
||||
Manually trigger the deletion process (for admin use).
|
||||
Deletes all marked users immediately without waiting for threshold.
|
||||
Returns stats about the run.
|
||||
"""
|
||||
logger.info("Manual deletion trigger requested")
|
||||
process_deletion_queue()
|
||||
logger.info("Manual deletion trigger requested - forcing immediate deletion")
|
||||
process_deletion_queue(force=True)
|
||||
|
||||
# Return stats (simplified version)
|
||||
Query_ = Query()
|
||||
|
||||
Reference in New Issue
Block a user