custom_user: provide more generic user-inactivity notifications (#74178)
gitea/authentic/pipeline/head Build queued...
Details
gitea/authentic/pipeline/head Build queued...
Details
Authentic now exposes a keepalive API endpoint, meaning that the user's last activity event was not necessarily a user login event.
This commit is contained in:
parent
e3ba72b7bd
commit
575cf199e6
|
@ -1,6 +1,6 @@
|
|||
{% load i18n humanize %}
|
||||
{% load i18n %}
|
||||
<p>{% blocktrans %}Hi {{ user }},{% endblocktrans %}</p>
|
||||
|
||||
<p>{% blocktrans with last_login_date=user.last_login|naturaltime %}Your last logging was {{ last_login_date }}.{% endblocktrans %}</p>
|
||||
<p>{% blocktrans %}Your account is inactive and is pending deletion.{% endblocktrans %}</p>
|
||||
<p>{% blocktrans %}In order to keep your account, you must <a href="{{ login_url }}">log in</a> within {{ days_to_deletion }} days.{% endblocktrans %}</p>
|
||||
<p>{% trans "Otherwise, it will be deleted after this time." %}</p>
|
||||
<p>{% trans "Past this delay, it will be deleted." %}</p>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% load i18n humanize %}{% blocktrans %}Hi {{ user }},{% endblocktrans %}
|
||||
{% load i18n %}{% blocktrans %}Hi {{ user }},{% endblocktrans %}
|
||||
|
||||
{% blocktrans with last_login_date=user.last_login|naturaltime %}Your last logging was {{ last_login_date }}.{% endblocktrans %}
|
||||
{% blocktrans %}Your account is inactive and is pending deletion.{% endblocktrans %}
|
||||
{% blocktrans %}In order to keep your account, you must log in within {{ days_to_deletion }} days.{% endblocktrans %}
|
||||
{% trans "Otherwise, it will be deleted after this time." %}
|
||||
{% trans "Past this delay, it will be deleted." %}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{% load i18n humanize %}{% blocktrans trimmed with last_login_date=user.last_login|naturaltime %}Alert: {{ user.get_full_name }} your last login was {{ last_login_date }}{% endblocktrans %}
|
||||
{% load i18n %}{% blocktrans trimmed %}Alert: {{ user }}, your account is inactive and is pending deletion{% endblocktrans %}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
{% load i18n %}
|
||||
<p>{% blocktrans %}Hi {{ user }},{% endblocktrans %}</p>
|
||||
|
||||
<p>{% blocktrans %}Your account was inactive, it has been deleted.{% endblocktrans %}</p>
|
|
@ -1,4 +1,4 @@
|
|||
{% load i18n humanize %}{% blocktrans with last_login_date=user.last_login|naturaltime %}
|
||||
Hi {{ user }},
|
||||
{% load i18n %}
|
||||
{% blocktrans %}Hi {{ user }},{% endblocktrans %}
|
||||
|
||||
Since your last logging was {{ last_login_date }}, your account has been deleted.{% endblocktrans %}
|
||||
{% blocktrans %}Your account was inactive, it has been deleted.{% endblocktrans %}
|
||||
|
|
|
@ -228,28 +228,29 @@ def test_clean_unused_account_always_alert(db, simple_user, mailoutbox, freezer)
|
|||
assert len(mailoutbox) == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"deletion_delay,formatted", [(730, '2\xa0years'), (500, '1\xa0year'), (65, '2\xa0months')]
|
||||
)
|
||||
def test_clean_unused_account_human_duration_format(simple_user, mailoutbox, deletion_delay, formatted):
|
||||
simple_user.ou.clean_unused_accounts_alert = deletion_delay - 1
|
||||
@pytest.mark.parametrize("deletion_delay", [730, 500, 65])
|
||||
def test_clean_unused_account_displayed_message(simple_user, mailoutbox, deletion_delay):
|
||||
simple_user.ou.clean_unused_accounts_alert = deletion_delay - 30
|
||||
simple_user.ou.clean_unused_accounts_deletion = deletion_delay
|
||||
simple_user.ou.save()
|
||||
simple_user.last_login = now() - datetime.timedelta(days=deletion_delay + 1)
|
||||
simple_user.last_login = now() - datetime.timedelta(days=deletion_delay + 30)
|
||||
simple_user.save()
|
||||
|
||||
# alert email
|
||||
call_command('clean-unused-accounts')
|
||||
mail = mailoutbox[0]
|
||||
assert formatted in mail.body
|
||||
assert formatted in mail.subject and not '\n' in mail.subject
|
||||
assert mail.subject == 'Alert: Jôhn Dôe, your account is inactive and is pending deletion'
|
||||
assert 'Jôhn Dôe' in mail.body
|
||||
assert 'In order to keep your account, you must log in within 30 days.' in mail.body
|
||||
|
||||
# deletion email
|
||||
simple_user.last_account_deletion_alert = now() - datetime.timedelta(days=2)
|
||||
simple_user.last_account_deletion_alert = now() - datetime.timedelta(days=31)
|
||||
simple_user.save()
|
||||
call_command('clean-unused-accounts')
|
||||
mail = mailoutbox[1]
|
||||
assert formatted in mail.body
|
||||
assert mail.subject == 'Notification: Jôhn Dôe, your account has been deleted'
|
||||
assert 'Jôhn Dôe' in mail.body
|
||||
assert 'Your account was inactive, it has been deleted.' in mail.body
|
||||
|
||||
|
||||
def test_clean_unused_account_login_url(simple_user, mailoutbox):
|
||||
|
|
Loading…
Reference in New Issue