Skip to main content

A django app for login with email.

Project description

Django Login Email

PyPI Documentation Status Downloads

Allow user to login and register with email address.

NOTICE: We are currently in the development stage. If you use this library, please upgrade to the latest version. Issues are welcome.

Install

pip install django-login-email

List of the urls for exmaple project:

  • /home for protected url.
  • /account/login for login.
  • /account/logout for logout.
  • /account/verify for email verify.

Feature

  • The developer could define their own User model.
  • Time-limited of login link.
  • limited of sending email. Using TimeLimt to set minutes.
  • The link could be used for Login once.
  • Register new user.
  • Support multiple user.
  • Ban the IP to send mail frequently without login.
  • Support django-templated-email
  • Support Django Anymail
  • Allow users to change their email address.
  • Enable 2FA.
  • More easier and customizable login link.

Usage

  • add django_login_email to your app settings.py.
INSTALLED_APP = [
    ...,
    'django_login_email',
    ...
]
  • Implement the LoginView, for example, like this:
from django.shortcuts import render
from django.urls import reverse

from django_login_email import email as e
from django_login_email import views as v

# Create your views here.

loginInfo, registerInfo = e.get_info_class("meterhub")


class LoginView(v.EmailLoginView):
  login_info_class = loginInfo
  register_info_class = registerInfo


class VerifyView(v.EmailVerifyView):
  def get_success_url(self):
    return reverse("home")


class LogoutView(v.EmailLogoutView):
  pass
  • set the view in your urls.py.
from django.contrib import admin
from django.urls import path
from <yourapp> import views as v
from django_login_email.views import HomeView

urlpatterns = [
    ...,
    path("account/login", v.LoginView.as_view(), name="login"),
    path("account/verify", v.VerifyView.as_view(), name="verify"),
    path("account/logout", v.LogoutView.as_view(), name="logout"),
    path("", HomeView.as_view(), name="home"),
]

That's all.

Debug the email with docker run -d --name mailhog -p 1025:1025 -p 8025:8025 mailhog/mailhog

Settings

  1. Config LoginView.tl to disable login attempts check.
  2. View settings/settings.py to config the email server account. As same as django official settings.
  3. Disable login check:
class YouLoginView(LoginView):
  def check_could_send(self, email) -> bool:
    # FOR DEBUG
    return True

Future

  • Academically prove the safety of this method.

Related project

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_login_email-0.6.1.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_login_email-0.6.1-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file django_login_email-0.6.1.tar.gz.

File metadata

  • Download URL: django_login_email-0.6.1.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for django_login_email-0.6.1.tar.gz
Algorithm Hash digest
SHA256 c805020ec5872682a52fc814d8d2f531f503dad74226cbdc67a55f19578f92ed
MD5 6b8cf31a92aee4584c0e85144568ed2b
BLAKE2b-256 7ec5ff44085f73ec2bb0a32a9d7a26749f468b11bd2e3aa9ecd2c73c79c88b06

See more details on using hashes here.

File details

Details for the file django_login_email-0.6.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_login_email-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5030a131bfb04bc2adf789d57d9bc68378fb1981c2b2b5097305b35aebe5982
MD5 9f929b575890f4de18c5c045c58169c1
BLAKE2b-256 087cd9e0dbe76ccb231d22bf7957463194daaa3d12d6e91022db9ab4dcd3e89e

See more details on using hashes here.

Supported by

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