Skip to main content

User model extender for django

Project description

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:

INSTALLED_APPS = [
    # ...
    'django_user_email_extension',
    # ...
]
# 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, an used address canot be save 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')

Run migrations:

python3 manage.py makemigrations python3 manage.py migrate

Optional:

add to settings.py, if not set, verification email will never expire.

    # ...
    DJANGO_EMAIL_VERIFIER_EXPIRE_TIME = 24  # In Hours
    # ...

Usage Example

use:

from django_user_email_extension.models import *

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

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

# Send the verification email
user_object.send_verification_email(subject=subject,
                                 body=body,
                                 from_mail=EMAIL_HOST_USER)

# Initiate verification process
verify_record(uuid_value=uuid)

The confirmation uuid can be sent as part of the body for example:

    body = 'Follow this link to verify your account: https://nalkins.cloud' + \
           '%s' % reverse('verify_account',
                          kwargs={'uuid': str(user_object.get_uuid_of_email())})

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-user-email-extension-2.1.1.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django-user-email-extension-2.1.1.tar.gz.

File metadata

  • Download URL: django-user-email-extension-2.1.1.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.8

File hashes

Hashes for django-user-email-extension-2.1.1.tar.gz
Algorithm Hash digest
SHA256 4c060ab9a16bbd8a1e2bd2bd5beb0df3f4fc02c5a9cd54f55879357795a0ae3a
MD5 e9c5b31c8377b4aa0ac2fe5849c0ccec
BLAKE2b-256 be298a9c8a4be7570154f09146bd78d4697d79dc0d765f7c2ee245785ba3729d

See more details on using hashes here.

Provenance

File details

Details for the file django_user_email_extension-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: django_user_email_extension-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 34.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.8

File hashes

Hashes for django_user_email_extension-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a0fd6860234fd86f20c9a662737b00e77afeff5c574a5722dfb8f64eee7cc978
MD5 460e9ea5792b2b4bfb3659de537768d6
BLAKE2b-256 65c7b7415471b4d87a225d84e40fb85128ece880ff719b7847af21c01b881554

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page