|
|
|
|
@ -3,12 +3,16 @@ from tournaments.models.court import Court |
|
|
|
|
from tournaments.models import Club, LiveMatch, TeamScore, Tournament, CustomUser, Event, Round, GroupStage, Match, TeamRegistration, PlayerRegistration, Purchase, FailedApiCall, DateInterval, Log, DeviceToken, UnregisteredTeam, UnregisteredPlayer |
|
|
|
|
from django.contrib.auth import password_validation |
|
|
|
|
from django.utils.translation import gettext_lazy as _ |
|
|
|
|
from django.db.utils import IntegrityError |
|
|
|
|
from django.conf import settings |
|
|
|
|
|
|
|
|
|
# email |
|
|
|
|
from django.template.loader import render_to_string |
|
|
|
|
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode |
|
|
|
|
from django.utils.encoding import force_bytes |
|
|
|
|
from django.core.mail import EmailMessage |
|
|
|
|
from django.contrib.sites.shortcuts import get_current_site |
|
|
|
|
|
|
|
|
|
from api.tokens import account_activation_token |
|
|
|
|
|
|
|
|
|
from shared.cryptography import encryption_util |
|
|
|
|
@ -48,6 +52,9 @@ class UserSerializer(serializers.ModelSerializer): |
|
|
|
|
if 'country' in validated_data: |
|
|
|
|
country = validated_data['country'] |
|
|
|
|
|
|
|
|
|
if CustomUser.objects.filter(username__iexact=validated_data['username'].lower()): |
|
|
|
|
raise IntegrityError("Le nom d'utilisateur existe déjà") |
|
|
|
|
|
|
|
|
|
user = CustomUser.objects.create_user( |
|
|
|
|
username=validated_data['username'], |
|
|
|
|
email=validated_data['email'], |
|
|
|
|
@ -73,7 +80,8 @@ class UserSerializer(serializers.ModelSerializer): |
|
|
|
|
origin=UserOrigin.APP, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
self.send_email(self.context['request'], user) |
|
|
|
|
if not settings.DEBUG: |
|
|
|
|
self.send_email(self.context['request'], user) |
|
|
|
|
# RegistrationProfile.objects.filter(user=user).send_activation_email() |
|
|
|
|
|
|
|
|
|
return user |
|
|
|
|
|