-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Django admin is missing some useful security features, e.g. read-only on critical fields. * A custom user model that extends the existing user model will allow some additional flexibility to customise the user. * Added django project custom user test suite and fixtures. * Added a custom user how-to. * Updated django-cookiecutter test suite. * Updated tutorial-create-django-project. * Updated README closes #207 closes #212
- Loading branch information
Showing
26 changed files
with
639 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,6 @@ | |
"False" | ||
], | ||
"SITE_ID": "1", | ||
"use_django_allauth": [ | ||
"y", | ||
"n" | ||
], | ||
"deploy_with_docker": [ | ||
"n", | ||
"y", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
.. include:: /extras.rst.txt | ||
.. highlight:: rst | ||
.. index:: cust-user-how-to ; Index | ||
|
||
.. _cust-user-how-to: | ||
=========== | ||
Custom User | ||
=========== | ||
|
||
By default, a Custom User employs django-allauth. | ||
|
||
The Custom User comes with custom user types. | ||
|
||
The CustomUser types have Admin panel filters and are sortable in the | ||
Users view. | ||
|
||
All Django Admin security and features remain intact. | ||
|
||
|
||
Options Before Initial Migration | ||
-------------------------------- | ||
|
||
CustomUser types can be left as is, or if you wish to change the user types | ||
to meet your needs, change the values in Users/models.py | ||
|
||
|
||
.. code-block:: python | ||
:caption: Customise these user types. | ||
class CustomUser(AbstractUser): | ||
class CustomUserType(models.TextChoices): | ||
"""Custom user type choices""" | ||
# Change these to suit your needs before initial migration. | ||
FREE = "FREE", _("Free") | ||
LEVEL_1 = "LEVEL 1", _("Level 1") | ||
LEVEL_2 = "LEVEL 2", _("Level 2") | ||
STAFF = "STAFF", _("Staff") | ||
SUPERUSER = "SUPERUSER", _("Superuser") | ||
Accessing Admin Panel | ||
--------------------- | ||
|
||
Additional security with your Custom User comes by default. | ||
|
||
You can only access your new Django project Admin after a successful login. | ||
|
||
Placing the Admin panel behind the django-allauth login gives Admin all the | ||
protections of django-allauth. | ||
|
||
If this behaviour does not suit your workflow, you can disable this feature by | ||
commenting out the line `admin.site.login`. | ||
|
||
.. code-block:: python | ||
:caption: Users/admin.py | ||
# Require login before Admin panel is available. Removes the opportunity for | ||
# a brute force attack on Admin Login. Provided by django-allauth. | ||
# https://django-allauth.readthedocs.io/en/latest/advanced.html | ||
# Comment the following line to disable django-allauth protection | ||
admin.site.login = login_required(admin.site.login) | ||
Adding a New User | ||
----------------- | ||
|
||
When creating a new user with the django-allauth Sign-up form, the Custom User | ||
model is used. | ||
|
||
.. note:: | ||
|
||
**Adding a new user via the Admin panel** | ||
|
||
The email should be entered under the Accounts menu when creating a new | ||
user in the Admin panel. | ||
|
||
Entering the email in this manner will ensure the email will be available to | ||
django-allauth. A search button will help locate the correct user. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.