django-user-email-extension


Namedjango-user-email-extension JSON
Version 2.4.2 PyPI version JSON
download
home_pagehttps://github.com/ArieLevs/Django-User-Email-Extension
SummaryUser model extender for django
upload_time2023-03-22 17:50:31
maintainer
docs_urlNone
authorArie Lev
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            Django-User-Email-Extension
===========================
[![](https://img.shields.io/pypi/l/django-user-email-extension.svg?colorB=blue)](https://pypi.org/project/django-user-email-extension/)
[![](https://img.shields.io/pypi/v/django-user-email-extension.svg)](https://pypi.org/project/django-user-email-extension/)
[![codecov](https://codecov.io/gh/ArieLevs/Django-User-Email-Extension/branch/master/graph/badge.svg?token=BLJTJKHCVY)](https://codecov.io/gh/ArieLevs/Django-User-Email-Extension)
[![](https://img.shields.io/pypi/pyversions/django-user-email-extension.svg)](https://pypi.org/project/django-user-email-extension/)
[![](https://img.shields.io/pypi/djversions/django-user-email-extension.svg)](https://pypi.org/project/django-user-email-extension/)

Django application that extends User module, and provides email verification process.

Install
-------
`pip install django-user-email-extension`

Add to installed apps, and email provider details:

```python
import os

INSTALLED_APPS = [
    # ...
    'django_user_email_extension',
    # ...
]

###############################
# Define the default user model 
###############################
AUTH_USER_MODEL = 'django_user_email_extension.User'

# if set then users age will be validated for minimal age (in years)
USER_MINIMAL_AGE = int(os.environ.get('USER_MINIMAL_AGE', None))

# if set, used address cannot be saved with non verified phone number
ENFORCE_USER_ADDRESS_VERIFIED_PHONE = int(os.environ.get('ENFORCE_USER_ADDRESS_VERIFIED_PHONE', False)) 

EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = os.environ.get('email_host')
EMAIL_PORT = os.environ.get('email_port')
EMAIL_HOST_USER = os.environ.get('email_username')
EMAIL_HOST_PASSWORD = os.environ.get('email_password')

# optional, if not set, verification email will never expire.
DJANGO_EMAIL_VERIFIER_EXPIRE_TIME = 24  # In Hours
```

Run migrations:
```shell script
python3 manage.py makemigrations
python3 manage.py migrate
```

Usage Example
-------------
use:

```python
from django.contrib.auth import get_user_model

User = get_user_model()

user_object = User.objects.create_user(
    email='EMAIL',
    password='PASSWORD'
)

# .save() must be called
# this option has been modified so extra action could be executed before final user creation
user_object.save()

# user is a Django User object
user_object.create_verification_email()

# Send the verification email
user_object.send_verification_email(
    subject=subject,
    body=body,  # *** view body example below to contain the unique UUID
    from_mail=EMAIL_HOST_USER
)
```
Then when user click the link (from the body sent via email)
```python
# make sure url is getting a uuid key in urls.py
path('verify_account/<uuid:verification_uuid>/', views.VerifyEmailUUIDView.as_view(), name='verify_account')

# initiate verification process on the return view
ver_uuid = DjangoEmailVerifier.objects.get(verification_uuid='UUID_FROM_REQUEST')
ver_uuid.verify_record()
```

The confirmation uuid can be sent as part of the body for example:
```python
body = 'Follow this link to verify your account: https://nalkins.cloud{}'.format(
    reverse('verify_account', kwargs={'verification_uuid': str(user_object.get_uuid_of_email())})
)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ArieLevs/Django-User-Email-Extension",
    "name": "django-user-email-extension",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Arie Lev",
    "author_email": "levinson.arie@gmail.com",
    "download_url": "",
    "platform": null,
    "description": "Django-User-Email-Extension\n===========================\n[![](https://img.shields.io/pypi/l/django-user-email-extension.svg?colorB=blue)](https://pypi.org/project/django-user-email-extension/)\n[![](https://img.shields.io/pypi/v/django-user-email-extension.svg)](https://pypi.org/project/django-user-email-extension/)\n[![codecov](https://codecov.io/gh/ArieLevs/Django-User-Email-Extension/branch/master/graph/badge.svg?token=BLJTJKHCVY)](https://codecov.io/gh/ArieLevs/Django-User-Email-Extension)\n[![](https://img.shields.io/pypi/pyversions/django-user-email-extension.svg)](https://pypi.org/project/django-user-email-extension/)\n[![](https://img.shields.io/pypi/djversions/django-user-email-extension.svg)](https://pypi.org/project/django-user-email-extension/)\n\nDjango application that extends User module, and provides email verification process.\n\nInstall\n-------\n`pip install django-user-email-extension`\n\nAdd to installed apps, and email provider details:\n\n```python\nimport os\n\nINSTALLED_APPS = [\n    # ...\n    'django_user_email_extension',\n    # ...\n]\n\n###############################\n# Define the default user model \n###############################\nAUTH_USER_MODEL = 'django_user_email_extension.User'\n\n# if set then users age will be validated for minimal age (in years)\nUSER_MINIMAL_AGE = int(os.environ.get('USER_MINIMAL_AGE', None))\n\n# if set, used address cannot be saved with non verified phone number\nENFORCE_USER_ADDRESS_VERIFIED_PHONE = int(os.environ.get('ENFORCE_USER_ADDRESS_VERIFIED_PHONE', False)) \n\nEMAIL_USE_TLS = True\nEMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'\nEMAIL_HOST = os.environ.get('email_host')\nEMAIL_PORT = os.environ.get('email_port')\nEMAIL_HOST_USER = os.environ.get('email_username')\nEMAIL_HOST_PASSWORD = os.environ.get('email_password')\n\n# optional, if not set, verification email will never expire.\nDJANGO_EMAIL_VERIFIER_EXPIRE_TIME = 24  # In Hours\n```\n\nRun migrations:\n```shell script\npython3 manage.py makemigrations\npython3 manage.py migrate\n```\n\nUsage Example\n-------------\nuse:\n\n```python\nfrom django.contrib.auth import get_user_model\n\nUser = get_user_model()\n\nuser_object = User.objects.create_user(\n    email='EMAIL',\n    password='PASSWORD'\n)\n\n# .save() must be called\n# this option has been modified so extra action could be executed before final user creation\nuser_object.save()\n\n# user is a Django User object\nuser_object.create_verification_email()\n\n# Send the verification email\nuser_object.send_verification_email(\n    subject=subject,\n    body=body,  # *** view body example below to contain the unique UUID\n    from_mail=EMAIL_HOST_USER\n)\n```\nThen when user click the link (from the body sent via email)\n```python\n# make sure url is getting a uuid key in urls.py\npath('verify_account/<uuid:verification_uuid>/', views.VerifyEmailUUIDView.as_view(), name='verify_account')\n\n# initiate verification process on the return view\nver_uuid = DjangoEmailVerifier.objects.get(verification_uuid='UUID_FROM_REQUEST')\nver_uuid.verify_record()\n```\n\nThe confirmation uuid can be sent as part of the body for example:\n```python\nbody = 'Follow this link to verify your account: https://nalkins.cloud{}'.format(\n    reverse('verify_account', kwargs={'verification_uuid': str(user_object.get_uuid_of_email())})\n)\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "User model extender for django",
    "version": "2.4.2",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d8c2772c582f69379bacf364331583d47b43f5706f80d7a314e0ee121c628090",
                "md5": "85d79cb1384a5a6c445e468d3507aab3",
                "sha256": "2dbcd8baf38a64a1137b498e20e453bcd571c8d4ee399c27a6571ff3572d389b"
            },
            "downloads": -1,
            "filename": "django_user_email_extension-2.4.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "85d79cb1384a5a6c445e468d3507aab3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 35192,
            "upload_time": "2023-03-22T17:50:31",
            "upload_time_iso_8601": "2023-03-22T17:50:31.459461Z",
            "url": "https://files.pythonhosted.org/packages/d8/c2/772c582f69379bacf364331583d47b43f5706f80d7a314e0ee121c628090/django_user_email_extension-2.4.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-22 17:50:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "ArieLevs",
    "github_project": "Django-User-Email-Extension",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "lcname": "django-user-email-extension"
}
        
Elapsed time: 0.05550s