Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9b14e96
django 5.1 compatibility
leolivier Aug 8, 2024
c9cd690
previous change was not done the right way
leolivier Aug 8, 2024
ec7b72b
changed envt
leolivier Aug 8, 2024
17003a8
publish on testpypi and release on pypi
leolivier Aug 8, 2024
110ca8d
use test secret for test pypi
leolivier Aug 8, 2024
f7975c3
change project name and version to be able to publish
leolivier Aug 8, 2024
6a370cd
description
leolivier Aug 9, 2024
67db0c4
fixed wrong code when no form is provided
leolivier Aug 9, 2024
c800969
raise exception on wrong http method
leolivier Aug 9, 2024
dc91ff6
changed version
leolivier Aug 9, 2024
e49c7a1
Merge pull request #1 from leolivier/v2.0.2
leolivier Aug 9, 2024
8271366
1rst try to modernize the packaging
leolivier Aug 9, 2024
e38a2a6
upgrade python version
leolivier Aug 9, 2024
0aab81c
typo
leolivier Aug 9, 2024
9d706da
changed package and project name
leolivier Aug 9, 2024
042b952
typo
leolivier Aug 9, 2024
adcf2ed
yet another typo
leolivier Aug 9, 2024
d42b143
use another project name to be allowed to upload to pypi
leolivier Aug 9, 2024
cee5b70
refactored to use trusted publishing
leolivier Aug 10, 2024
e5a79e2
added upload/download dist
leolivier Aug 10, 2024
504b7c5
changed path of upload
leolivier Aug 10, 2024
145e3dc
added manual unzip of dist
leolivier Aug 10, 2024
550ddbd
unzip using the action itself
leolivier Aug 10, 2024
5f2c94e
OIDC Connect error. Tries w/o url on ChatGPT advice
leolivier Aug 10, 2024
7f892f4
verbose try
leolivier Aug 10, 2024
bc8ac98
removed all unused urls + changed publisher on test.pypi.org
leolivier Aug 10, 2024
4586b66
OIDC issue is due to the project name
leolivier Aug 10, 2024
4010e37
removed verbose
leolivier Aug 10, 2024
6e2cfcc
removed binascii from dependencies
leolivier Aug 10, 2024
c7b2982
moved to v2.0.5
leolivier Aug 11, 2024
9aceeda
localization - 1rst try
leolivier Feb 2, 2025
debe0c6
mo files were filtered
leolivier Feb 2, 2025
7de9638
2.1.1
leolivier Feb 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 65 additions & 17 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,75 @@

name: Upload Python Package
name: Upload Python Package to PyPi

on: [push]
on:
push:
branches: []
tags-ignore: []

release:
types: [prereleased, published]

jobs:
build:
runs-on: ubuntu-latest
name: build python package
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python3 -m pip install --upgrade build
- name: Build package
run: python -m build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

deploy:
if: github.event_name == 'release'
needs: build
runs-on: ubuntu-latest
name: Upload Python Package to PyPi on release

environment:
name: pypi-release

permissions:
id-token: write

steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish package to pypi if release
uses: pypa/gh-action-pypi-publish@release/v1

deploy-test:
if: github.event_name == 'push'
needs: build
runs-on: ubuntu-latest
name: Upload Python Package to Test PyPi on push

environment:
name: pypi-test

permissions:
id-token: write

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish package to test.pypi if push
uses: pypa/gh-action-pypi-publish@release/v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload --skip-existing dist/*
repository-url: https://test.pypi.org/legacy/


1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ coverage.xml
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
Expand Down
39 changes: 33 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,43 @@


<h1 style='text-align:center'>Email-Verification for Django</h1>
# Email Verification for Django

Email verification for new signups or new users is a two-step verification process and adds a layer for security for valid users.

<b> verify_email </b> is a django app that provides this functionality right of the bat without any complex implementation.
**verify_email** is a django app that provides this functionality right of the bat without any complex implementation.

<hr>
## Version Update (2.0.4)
#### Bug fixes
* Solves incompatibility with Django 5.1 (exception when initializing the TokenManager)
* Fixes implementation of sending verification without a form (initial PR by )

## Version Update (2.0.0):
#### Enhancements
* Verification emails can now be sent without a form if a user has already been created (eg when an admin wants to activate an inactive user) (Inspired by other PRs which were buggy, see above)
* Modernized the Python packaging (removed warnings on build)
* Use of GITHUB TOKEN to build

## Version Update (v2.0.3)

#### Bug Fixes:
* Variable name in view function was different than the one passed in URL

#### Enhancement:
* Raising Http404 instead of returning 404 with a string so we can have the default 404 page
* Using python's logging system instead of print statements

<hr>

## Version Update (2.0.2):
#### Bug Fixes:
* Using normal form instead of model forms to allow unique emails to re-request verification email
* Not returning HTTP response in one of the exception blocks

#### Enhancements:
* Added new settings variable NEW_EMAIL_SENT_TEMPLATE to configure template shown after successful email sent.
* Using get_username() method to account for apps that have changed the USERNAME_FIELD of their user model
* migrations updated according to Django 4.x


## Version Update (2.0.0):

> This version contains breaking changes and is not compatible with the previous version 1.0.9

Expand All @@ -29,7 +56,7 @@ Read about this feature <a href='#resending-email-using-form'>here</a>
* Using exceptions instead of normal string errors
* code cleanup

<hr><hr>
<hr>

## The app takes care of :
* Settings user's is_active status to False.
Expand Down
22 changes: 22 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
"""Run administrative tasks."""
# os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'cousinsmatter.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
35 changes: 35 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "django-email-validation"
version = "2.1.1"
#dynamic = ["version"]
authors = [
{ name="Nitin Sharma", email="ns290670@gamil.com"},
{ name="Olivier LEVILLAIN", email="levillain.olivier@gmail.com" },
]
description = " A Django app for email verification."
readme = "README.md"
requires-python = ">=3.6"
dependencies=["django"]
classifiers = [
"Environment :: Web Environment",
"Framework :: Django CMS :: 3.8",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3.6",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent"
]

keywords = ["email", "validation", "check"]

[project.urls]
Homepage = "https://github.com/foo290/Django-Verify-Email/"
Repository = "https://github.com/foo290/Django-Verify-Email.git"
Issues = "https://github.com/foo290/Django-Verify-Email//issues"
Download = "https://github.com/foo290/Django-Verify-Email/archive/refs/tags/2.0.4.tar.gz"

[tool.hatch.build.targets.wheel]
packages = ["src/verify_email"]
20 changes: 0 additions & 20 deletions setup.cfg

This file was deleted.

9 changes: 0 additions & 9 deletions setup.py

This file was deleted.

1 change: 1 addition & 0 deletions src/verify_email/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .email_handler import * # noqa
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.conf import settings
from django.utils.translation import gettext as _


class GetFieldFromSettings:
Expand Down Expand Up @@ -27,12 +28,12 @@ def __init__(self):

'subject': (
"SUBJECT",
"Email Verification Mail"
_("Email Verification Mail")
),

'email_field_name': (
"EMAIL_FIELD_NAME",
"email",
_("email"),
),

'html_message_template': (
Expand All @@ -57,8 +58,8 @@ def __init__(self):

'verification_success_msg': (
'VERIFICATION_SUCCESS_MSG',
"Your Email is verified successfully and account has been activated. "
"You can login with the credentials now..."
_("Your Email is verified successfully and account has been activated. "
"You can login with the credentials now...")
),

'verification_failed_template': (
Expand All @@ -73,7 +74,7 @@ def __init__(self):

'verification_failed_msg': (
'VERIFICATION_FAILED_MSG',
"There is something wrong with this link, can't verify the user..."
_("There is something wrong with this link, can't verify the user...")
),
'request_new_email_template': (
'REQUEST_NEW_EMAIL_TEMPLATE',
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,20 @@ def __send_email(self, msg, useremail):
)

# Public :
def send_verification_link(self, request, inactive_user=None, form=None):

def send_verification_link(self, request, form=None, inactive_user=None):

if not form and not inactive_user:
raise ValueError('Either form or inactive_user must be provided')
elif form and inactive_user:
raise ValueError('Either form or inactive_user must be provided')
if form:
inactive_user = form.save(commit=False)

inactive_user.is_active = False
inactive_user.save()

try:

useremail = form.cleaned_data.get(self.settings.get('email_field_name')) if form else inactive_user.email
if not useremail:
raise KeyError(
Expand Down Expand Up @@ -67,7 +71,7 @@ def resend_verification_link(self, request, email, **kwargs):
- UserAlreadyActive (by) get_user_by_token()
- MaxRetryExceeded (by) request_new_link()
- InvalidTokenOrEmail

These exception should be handled in caller function.
"""
inactive_user = kwargs.get('user')
Expand All @@ -92,10 +96,9 @@ def resend_verification_link(self, request, email, **kwargs):
return True



# These is supposed to be called outside of this module
def send_verification_email(request, form):
return _VerifyEmail().send_verification_link(request, form)
def send_verification_email(request, form=None, inactive_user=None):
return _VerifyEmail().send_verification_link(request, form, inactive_user)


# These is supposed to be called outside of this module
Expand Down
File renamed without changes.
File renamed without changes.
Binary file added src/verify_email/locale/de/LC_MESSAGES/django.mo
Binary file not shown.
Loading