django-allauth:在电子邮件确认之前不要让用户登录

django-allauth: do not let user sign in before email confirmation

使用 django-allauth 后台注册后,用户 both 登录 并且 发送了一个验证邮件。问题是,我只想让用户在 验证了他的电子邮件地址后才登录。

我该怎么做?我担心某些用户可能会使用虚假帐户向我的网站发送垃圾邮件。提前致谢。

您必须设置 ACCOUNT_EMAIL_VERIFICATION='mandatory',默认设置为 optional

Determines the e-mail verification method during signup – choose one of "mandatory", "optional", or "none".

Setting this to “mandatory” requires ACCOUNT_EMAIL_REQUIRED to be True

When set to “mandatory” the user is blocked from logging in until the email address is verified. Choose “optional” or “none” to allow logins with an unverified e-mail address. In case of “optional”, the e-mail verification mail is still sent, whereas in case of “none” no e-mail verification mails are sent.

Documentation