Reusable TOMToolkit app to support multiple user registration flows.
Project description
TOM Registration
This reusable TOM Toolkit app provides support for two user registration flows in the TOM Toolkit.
The two registration flows are as follows:
-
Open Registration - In this flow, the user fills in a registration form and is immediately able to access the TOM as a member of the Public Group.
-
Approval Registration - In this flow, the user fills in a registration form, and is inactive until an administrator reviews and approves their registration.
Installation
-
Install the package into your TOM environment:
pip install tom_registration
-
In your project
settings.py
, addtom_registration
to yourINSTALLED_APPS
setting:INSTALLED_APPS = [ ... 'tom_registration', ]
And add the follow setting, with appropriate values for your use case:
TOM_REGISTRATION = { 'REGISTRATION_AUTHENTICATION_BACKEND': 'django.contrib.auth.backends.ModelBackend', 'REGISTRATION_REDIRECT_PATTERN': 'home', 'SEND_APPROVAL_EMAILS': True }
To prevent logged-in users from accessing the registration page, add
RedirectAuthenticatedUsersFromRegisterMiddleware
to theMIDDLEWARE
settings:MIDDLEWARE = [ ... 'tom_common.middleware.AuthStrategyMiddleware', 'tom_registration.middleware.RedirectAuthenticatedUsersFromRegisterMiddleware', ]
-
Depending on your preferred registration flow, include the appropriate tom_registration URLconf in your project
urls.py
. You will need to ensure that this urlpattern appears in the list before yourtom_common.urls
.
Open Registration:
```python
urlpatterns = [
...
path('', include('tom_registration.registration_flows.open.urls', namespace='registration')),
]
```
Approval Registration:
```python
urlpatterns = [
...
path('', include('tom_registration.registration_flows.approval_required.urls', namespace='registration')),
]
```
- While the registration views are now accessible directly, some changes need to be made to templates to make them available.
Copy the contents of this file to templates/tom_common/partials/navbar_login.html
.
If you're using approval registration, copy the contents of this file to templates/auth/user_list.html
.
- If you're using approval registration and you would like a message informing the user that their account is pending approval if they try to log in prior to approval, you'll need to make the following changes:
First, in your settings.py
, set the first item of your AUTHENTICATION_BACKENDS
:
```python
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.AllowAllUsersModelBackend',
'guardian.backends.ObjectPermissionBackend'
)
```
Then, change the value of REGISTRATION_AUTHENTICATION_BACKEND
in the TOM_REGISTRATION
setting that was just created:
```python
TOM_REGISTRATION = {
'REGISTRATION_AUTHENTICATION_BACKEND': 'django.contrib.auth.backends.AllowAllUsersModelBackend`,
...
}
```
In the approval required registration flow, there is available behavior to send basic emails notifying administrators of a registration request, and notifying users of registration approval. Administrators are determined by the Django MANAGERS setting. Email behavior can be enabled or disabled with SEND_APPROVAL_EMAILS
.
The configuration of an email backend is a topic covered in depth by the Django docs. There are a number of required settings that will need to be added.
In the future, tom_registration
will provide more configurable behavior upon user registration/approval.
Running the tests
In order to run the tests, run the following in your virtualenv:
python manage.py test
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file tom-registration-0.1.0.tar.gz
.
File metadata
- Download URL: tom-registration-0.1.0.tar.gz
- Upload date:
- Size: 31.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb4971aad9254f42e930176ab36da3ab3b0a415620f67d3f3d4965b046ee6c6a |
|
MD5 | 6a6c05d9f4d5c050560d20d248ba0aee |
|
BLAKE2b-256 | 70ef6735229e076df0b33aa983cc28dc12944084cf845a93fbe1e3c047db846d |
File details
Details for the file tom_registration-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: tom_registration-0.1.0-py3-none-any.whl
- Upload date:
- Size: 32.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.0 importlib_metadata/3.7.3 packaging/20.9 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc8a82eda322804002dad9a0393550782cc75c5657a423ac2480d88777de11ab |
|
MD5 | 8a97ae930e949d712da3b0a7317f4a9f |
|
BLAKE2b-256 | 816b03f291863a6b08df81154de7cfe474951d8a51f0d9a720cb49a37516842e |