8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-22 11:23:10 +00:00

Show warning with delay before account suspension for users

This commit is contained in:
Jean-Romain Garnier 2020-04-17 14:08:54 +02:00 committed by Gabriel Detraz
parent 02040bfae9
commit 65a91c1110
4 changed files with 17 additions and 2 deletions

View file

@ -32,7 +32,7 @@ class Command(BaseCommand):
def handle(self, *args, **options):
"""First deleting invalid invoices, and then deleting the users"""
days = OptionalUser.get_cached_value("delete_notyetactive")
days = OptionalUser.get_cached_value("disable_emailnotyetconfirmed")
users_to_delete = (
User.objects.filter(Q(state=User.STATE_NOT_YET_ACTIVE) | Q(state=User.STATE_DISABLED))
.filter(registered__lte=timezone.now() - timedelta(days=days))

View file

@ -62,6 +62,7 @@ from django.core.mail import send_mail
from django.core.urlresolvers import reverse
from django.db import transaction
from django.utils import timezone
from datetime import timedelta
from django.contrib.auth.models import (
AbstractBaseUser,
BaseUserManager,
@ -803,6 +804,13 @@ class User(
)
return
def confirm_email_before_date(self):
if self.email_change_date is None or self.state != self.STATE_EMAIL_NOT_YET_CONFIRMED:
return None
days = OptionalUser.get_cached_value("disable_emailnotyetconfirmed")
return str(self.email_change_date + timedelta(days=days))
def confirm_email_address_mail(self, request):
"""Prend en argument un request, envoie un mail pour
confirmer l'adresse"""
@ -821,6 +829,7 @@ class User(
reverse("users:process", kwargs={"token": req.token})
),
"expire_in": str(GeneralOption.get_cached_value("req_expire_hrs")),
"confirm_before": self.confirm_email_before_date(),
}
send_mail(
"Confirmation de l'email de %(name)s / Email confirmation for "

View file

@ -9,6 +9,9 @@ de vos équipements, votre compte, vos factures, et tous les services proposés
Contactez les administrateurs si vous n'êtes pas à l'origine de cette requête.
Ce lien expirera dans {{ expire_in }} heures.
S'il a expiré, vous pouvez renvoyer un mail de confirmation depuis votre compte {{ site_name }}.
<strong>Attention :</strong> Si vous ne confirmez pas votre email avant le {{ confirm_before }}, votre compte sera suspendu.
Respectueusement,
@ -27,6 +30,9 @@ the services offered on the network.
Contact the administrators if you didn't request this.
This link will expire in {{ expire_in }} hours.
If it has expired, you can send a new confirmation email from your account on {{ site_name }}.
<strong>Warning:</strong> If you do not confirm your email before {{ confirm_before }}, your account will be suspended.
Regards,

View file

@ -42,7 +42,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% if users.state == users.STATE_EMAIL_NOT_YET_CONFIRMED %}
<div class="alert alert-warning">
{% blocktrans %}Please confirm your email address.{% endblocktrans %}
{% blocktrans %}Please confirm your email address before {{ users.confirm_email_before_date }}, or your account will be suspended.{% endblocktrans %}
<br/>
<a href="{% url 'users:resend-confirmation-email' users.id %}">
{% blocktrans %}Didn't receive the email?{% endblocktrans %}