mirror of
https://github.com/wizarrrr/wizarr.git
synced 2026-08-02 00:06:25 -04:00
- Introduced `is_disabled` attribute to the User model. - Added `expiry_action` selection in the GeneralSettingsForm for user management. - Implemented `disable_user` methods for various media clients (Audiobookshelf, Jellyfin, Kavita, etc.) to handle user disabling. - Updated `check_expiring` task to process expired users based on the new settings. - Enhanced user interface to reflect disabled status in user cards. - Added migration for the new `is_disabled` column in the user table.
45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
import logging
|
|
import os
|
|
|
|
from app.services.expiry import (
|
|
disable_or_delete_user_if_expired,
|
|
)
|
|
|
|
|
|
def _get_expiry_check_interval():
|
|
"""Get the interval for expiry checks based on environment."""
|
|
# Use 1 minute for development, 15 minutes for production
|
|
if os.getenv("WIZARR_ENABLE_SCHEDULER") == "true":
|
|
return 1 # Development mode: every 1 minute
|
|
return 15 # Production mode: every 15 minutes
|
|
|
|
|
|
def check_expiring(app=None):
|
|
"""Check for and process expired users based on expiry action setting.
|
|
|
|
Args:
|
|
app: Flask application instance. If None, will try to get from current context.
|
|
"""
|
|
if app is None:
|
|
from flask import current_app
|
|
|
|
try:
|
|
app = current_app._get_current_object() # type: ignore
|
|
except RuntimeError:
|
|
# If we're outside application context, we need the app to be passed
|
|
logging.error(
|
|
"check_expiring called outside application context and no app provided"
|
|
)
|
|
return
|
|
|
|
with app.app_context():
|
|
processed = disable_or_delete_user_if_expired()
|
|
if len(processed) > 0:
|
|
logging.info(
|
|
"🧹 Expiry cleanup: Processed %s expired users.", len(processed)
|
|
)
|
|
else:
|
|
# Only log in development mode to avoid spam in production logs
|
|
if os.getenv("WIZARR_ENABLE_SCHEDULER") == "true":
|
|
logging.info("🕒 Expiry cleanup: No expired users found.")
|