Django Rest User Invitation
The primary aim of this python package is to provides a simple user invitation strategy for django rest framework, where users can be invited using invitation tokens (by sending email to the provided e-mail address).
This package provides a REST endpoint that verifies an token and set the password for that particular user.
Quick Start
- Install the package from pypi using pip:
pip install drf-simple-invite
- Add
drf_simple_inviteto yourINSTALLED_APPS(afterrest_framework) within your Django settings file:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Third party apps
'rest_framework', # utilities for rest apis
'rest_framework.authtoken', # token
# Simple Invite
'drf_simple_invite',
# Custom User Model
'users',
]
- This package provides an endpoint, which can be included by including
drf_simple_invite.urlsin yoururls.pyas follows:
from django.urls import re_path as url, include
urlpatterns = [
url(r'api/v1/invite/', include('drf_simple_invite.urls', namespace='drf_simple_invite')),
]
Note: You can adapt the api-url to your needs.
Endpoints
The following endpoints are provided:
POST ${API_URL}/- invite the user by sending the email as parameterPOST ${API_URL}/{invitation_token}- set password token by using theinvitation_tokenparameter
where ${API_URL}/ is the url specified in your urls.py (e.g., api/v1/invite/)
and {invitation_token} is base64.urlsafe encoded uuid token. Since it is unsafe to use plain uuid, always make sure that the {invitation_token} is base64.urlsafe encoded
Signals
invitation_token_created- Fired when a reset password token is generatedpre_password_creation- fired just before a password is being setpost_password_creation- fired after a password has been set
TODO: Configuration / Settings / Management Command
The following settings can be set in Django settings.py file:
DJANGO_REST_INVITATION_TOKEN_EXPIRY_TIME- time in hours about how long the token is active (Default: 24)
Please note: expired tokens are automatically cleared based on this setting in every call of post method on this endpoint.
Release files for drf-simple-invite 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| drf_simple_invite-0.3.0.tar.gz | 7.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| drf_simple_invite-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.8 kB
Release files / drf_simple_invite-0.3.0.tar.gz
| Download URL | drf_simple_invite-0.3.0.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d35f29407ac148decc53061b511a97f7aca559a2096e00c273b9ea05d29e65cb
|
|
BLAKE2b-256 checksum How to use checksums |
6351912a1efe69bbdcf27db3102e64f72a0f71d0537c5d565f3b3166725fbda6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / drf_simple_invite-0.3.0-py3-none-any.whl
| Download URL | drf_simple_invite-0.3.0-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7fa352164638df5a44b02acc2cc25ffb1a969d0d099839c679cc1b8afee699d3
|
|
BLAKE2b-256 checksum How to use checksums |
01433b2e1678cc819184f61f61484a2e52004c5c779b253bf90fa2a0cbdcc7c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|