繁体   English   中英

Django allauth停止电子邮件确认

[英]Django allauth stopping email confirmation

在我的Web应用程序中,我使用django-allauth进行帐户管理。

如果用户在我的应用程序中注册,他们将收到带有“确认链接”的电子邮件。(无需确认电子邮件,他们可以登录但不会获得完整权限)。

现在,我想延迟发送确认电子邮件,因为他们可以执行一些操作以导致表中的更新。 如果用户执行了这些操作(如果表已更新),则只需要发送该确认电子邮件即可。我正在考虑在此处使用信号。

from django.db import models
from django.contrib.auth.models import User
from allauth.account.signals import user_signed_up
from allauth.account.utils import send_email_confirmation
from django.dispatch import receiver
import datetime


#this signal will be called when user signs up.
@receiver(user_signed_up, dispatch_uid="some.unique.string.id.for.allauth.user_signed_up")
def user_signed_up_(request, user, **kwargs):

    send_email_confirmation(request, user, signup=True)
    #this allauth util method, which sends confirmation email to user.


class UserProfile(models.Model):
    user = models.ForeignKey(User, unique=True)

    are_u_intrested = models.BooleanField(default=False)


models.signals.post_save.connect(user_signed_up_, sender=UserProfile, dispatch_uid="update_stock_count")

#If user fills this userProfile , then I only send confirmation mail.
#If UserProfile model instace saved , then it send post_save signal.

编辑-

我能想到的一种方法是将ACCOUNT_EMAIL_VERIFICATION设置为"none" ,然后在用户将这些字段添加到数据库后调用allauths send_email_confirmation方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM