[英]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.