mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-25 22:22:26 +00:00
Correction de bugs et ajout d'un message
This commit is contained in:
parent
badc111491
commit
faf6e4fc93
2 changed files with 12 additions and 6 deletions
|
@ -48,6 +48,7 @@ from __future__ import unicode_literals
|
|||
import re
|
||||
import uuid
|
||||
import datetime
|
||||
from pytz import timezone
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
|
@ -414,7 +415,8 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
|||
|
||||
def has_access(self):
|
||||
""" Renvoie si un utilisateur a accès à internet """
|
||||
if(OptionalUser.get_cached_value('mail_verification') and not self.verified and self.verification_deadline is not None and datetime.datetime.now() > self.verification_deadline):
|
||||
now = datetime.datetime.now(datetime.timezone.utc)
|
||||
if(OptionalUser.get_cached_value('mail_verification') and not self.verified and self.verification_deadline is not None and now > self.verification_deadline):
|
||||
verified = False
|
||||
else:
|
||||
verified = True
|
||||
|
@ -589,7 +591,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
|||
)
|
||||
return
|
||||
|
||||
def send_verification_mail(self, request):
|
||||
def send_verification_mail(self, request):
|
||||
""" Prend en argument un request, envoie un mail de
|
||||
vérification"""
|
||||
req = Request()
|
||||
|
@ -610,7 +612,7 @@ def send_verification_mail(self, request):
|
|||
) + ' heures',
|
||||
}
|
||||
send_mail(
|
||||
'Changement du compte de %(name)s / Account verification for '
|
||||
'Vérification du compte de %(name)s / Account verification for '
|
||||
'%(name)s' % {'name': AssoOption.get_cached_value('name')},
|
||||
template.render(context),
|
||||
GeneralOption.get_cached_value('email_from'),
|
||||
|
@ -653,7 +655,7 @@ def send_verification_mail(self, request):
|
|||
def verification_message(self):
|
||||
if(OptionalUser.get_cached_value('mail_verification') and not self.verified):
|
||||
if(self.verification_deadline is not None):
|
||||
message = 'Votre adresse mail n\'est pas vérifiée. Si vous ne vérifiez pas votre adresse mail, toute connexion sera intérrompu le ' + self.verification_deadline
|
||||
message = 'Votre adresse mail n\'est pas vérifiée. Si vous ne vérifiez pas votre adresse mail, toute connexion sera intérrompu le ' + str(self.verification_deadline)
|
||||
else:
|
||||
message = 'Votre adresse mail n\'est pas vérifiée.'
|
||||
return message
|
||||
|
|
|
@ -34,6 +34,7 @@ des whitelist, des services users et des écoles
|
|||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import datetime
|
||||
|
||||
from django.urls import reverse
|
||||
from django.shortcuts import get_object_or_404, render, redirect
|
||||
|
@ -113,7 +114,8 @@ def new_user(request):
|
|||
if user.is_valid():
|
||||
password = user.cleaned_data['password2']
|
||||
user = user.save(commit=False)
|
||||
if(OptionalUser.get_cached_value('mail_verification'):
|
||||
user.save()
|
||||
if(OptionalUser.get_cached_value('mail_verification')):
|
||||
user.send_verification_mail(request)
|
||||
messages.warning(request, "Un mail pour vérifier l'adresse a été envoyé")
|
||||
if(OptionalUser.get_cached_value('verification_time')>0):
|
||||
|
@ -961,11 +963,13 @@ def process(request, token):
|
|||
user = req.user
|
||||
user.verified = True
|
||||
user.save()
|
||||
messages.success(request, "Le compte a bien été vérifié")
|
||||
return process_passwd(request, req)
|
||||
elif req.type == Request.EMAIL:
|
||||
user = req.user
|
||||
user.verified= True
|
||||
user.save()
|
||||
messages.success(request, "Le compte a bien été vérifié")
|
||||
return redirect(reverse('login'))
|
||||
else:
|
||||
messages.error(request, "Entrée incorrecte, contactez un admin")
|
||||
|
|
Loading…
Reference in a new issue