Example #1
0
    def send_confirmation(self):
        email = self.cleaned_data["email_add_merge"]

        try:
            pk_merge = Person.objects.get(email=email).pk
        except Person.DoesNotExist:
            if self.is_rate_limited():
                return [None, None]

            # l'utilisateur n'existe pas. On envoie une demande d'ajout d'adresse e-mail
            send_confirmation_change_email.delay(
                new_email=email, user_pk=str(self.user_pk)
            )
            return [email, False]
        else:
            if pk_merge == self.user_pk:
                self.add_error(
                    "email_add_merge",
                    self.fields["email_add_merge"].error_messages["same_person"],
                )
                return [None, None]

            # l'utilisateur existe. On envoie une demande de fusion de compte
            if self.is_rate_limited():
                return [None, None]
            send_confirmation_merge_account.delay(self.user_pk, pk_merge)
            return [email, True]
Example #2
0
    def send_confirmation(self, user_pk):
        new_mail = self.cleaned_data["address"]
        if not ChangeMailBucket.has_tokens(user_pk):
            self.add_error("address",
                           self.fields["address"].error_messages["rate_limit"])
            return None

        send_confirmation_change_email.delay(new_email=new_mail,
                                             user_pk=str(user_pk))
        return new_mail