0001-a2_rbac-provide-default-values-for-unused-account-th.patch
src/authentic2/app_settings.py | ||
---|---|---|
333 | 333 |
default=250, |
334 | 334 |
definition='Maximum number of mails to send per period', |
335 | 335 |
), |
336 |
A2_CLEAN_UNUSED_ACCOUNTS_DELETION=Setting( |
|
337 |
default=365, |
|
338 |
definition='Default delay in days before cleaning unused accounts', |
|
339 |
), |
|
340 |
A2_CLEAN_UNUSED_ACCOUNTS_ALERT=Setting( |
|
341 |
default=335, |
|
342 |
definition='Default delay after which the user receives an account deletion alert', |
|
343 |
), |
|
336 | 344 |
) |
337 | 345 | |
338 | 346 |
app_settings = AppSettings(default_settings) |
src/authentic2/management/commands/clean-unused-accounts.py | ||
---|---|---|
90 | 90 | |
91 | 91 |
# send first alert |
92 | 92 |
inactive_users_first_alert = inactive_users.filter(last_account_deletion_alert__isnull=True) |
93 |
days_to_deletion = ou.clean_unused_accounts_deletion - ou.clean_unused_accounts_alert |
|
93 |
clean_unused_accounts_deletion = ( |
|
94 |
ou.clean_unused_accounts_deletion or settings.A2_CLEAN_UNUSED_ACCOUNTS_DELETION |
|
95 |
) |
|
96 |
clean_unused_accounts_alert = ( |
|
97 |
ou.clean_unused_accounts_alert or settings.A2_CLEAN_UNUSED_ACCOUNTS_ALERT |
|
98 |
) |
|
99 |
days_to_deletion = clean_unused_accounts_deletion - clean_unused_accounts_alert |
|
94 | 100 |
for user in inactive_users_first_alert[:count]: |
95 | 101 |
logger.info('%s last login %d days ago, sending alert', user, ou.clean_unused_accounts_alert) |
96 | 102 |
self.send_alert(user, days_to_deletion) |
97 |
- |