File: decorators.rst

package info (click to toggle)
django-allauth 0.38.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,612 kB
  • sloc: python: 15,213; xml: 849; makefile: 138
file content (26 lines) | stat: -rw-r--r-- 780 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Decorators
==========

Verified E-mail Required
------------------------

Even when email verification is not mandatory during signup, there
may be circumstances during which you really want to prevent
unverified users from proceeding. For this purpose you can use the
following decorator::

    from allauth.account.decorators import verified_email_required

    @verified_email_required
    def verified_users_only_view(request):
        ...

The behavior is as follows:

- If the user isn't logged in, it acts identically to the
  ``login_required`` decorator.

- If the user is logged in but has no verified e-mail address, an
  e-mail verification mail is automatically resent and the user is
  presented with a page informing them they need to verify their email
  address.