Search code examples
djangodjango-allauthemail-verificationloginview

Django all-auth allow users to login only if the user email address is verified


How do i override AllAuth default LoginView to allow users to login only if their email address is verified?


Solution

  • From the Aullauth configuration docs

    You need to set: ACCOUNT_EMAIL_VERIFICATION="mandatory"

    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.

    Also keep in mind before setting it you need to also set ACCOUNT_EMAIL_REQUIRED=True

    Setting this to “mandatory” requires ACCOUNT_EMAIL_REQUIRED to be True