Django Allauth Sniperlinks
django-allauth-sniperlinks is a Django app to provide sniper links, allowing users to quickly find account verification/confirmation emails in their inbox.
Development supported by Subscribe Sense, which provides hosted sniper link support and other friction reduction for marketing email list signup.
The package integrates with the amazing Django Allauth package.
Quick start
-
Add "allauth_sniperlinks" to your INSTALLED_APPS setting before the allauth package like this:
INSTALLED_APPS = [ ... 'allauth_sniperlinks', 'allauth', ... ] -
Add "allauth_sniperlinks.context_processors.unverified_email_sniperlinks" to the 'context_processors' option in your TEMPLATES setting:
TEMPLATES = [ { ... 'OPTIONS': { 'context_processors': [ ... 'allauth_sniperlinks.context_processors.unverified_email_sniperlinks', ... ], }, ... }, ] -
In settings, set
ACCOUNT_ADAPTER="allauth_sniperlinks.adapter.SniperLinkAccountAdapter".If you have already overridden the account adapter to support another allauth package, you may need to create a custom account adapter that inherits from both adapters.
E.g. in myapp/adapters.py:
from allauth_sniperlinks.adapter import SniperLinkAccountAdapter from apps.teams.adapter import AcceptInvitationAdapter class MyappAccountAdapter(AcceptInvitationAdapter, SniperLinkAccountAdapter): passAnd in settings.py:
ACCOUNT_ADAPTER = 'myapp.adapters.MyappAccountAdapter' -
Run python manage.py migrate to create the allauth_sniperlinks models.
Features
-
Out of the box, a button with a sniper link for the email address submitted will be included in the message that appears after a verification email has been sent, e.g.:
The button will open up the users webmail browser in another tab and attempt to pull up any emails sent from the address configured by ALLAUTH_SNIPERLINKS_VERIFICATION_SENDER.
You can override the display of this button by copying the file
templates/account/messages/email_confirmation_sent.txtinto your own template directory and changing the html directly.The icon will change to match the webmail provider. See models.MailProviders for a list of currently supported webmail providers.
Unsupported mail providers will not show a sniper link button.
-
A
unverified_email_bannertemplate tag can be included in your main template which will display a banner with a prompt to verify their email address and a sniper link, if they have an unverified email address. To access this, include{% load sniperlink_tags %}in your template, e.g.:{% load sniperlink_tags %} {# Output the unverified email banner, if applicable #} {% unverified_email_banner %}You can add classes to the banner and button link objects by passing in
banner_classandlink_classvariables, like this:{% unverified_email_banner banner_class="bg-yellow-100 my-2 py-1" link_class="button bg-blue-700 text-white" %}If a user had two unverified email addresses associated with their account, this would result in banners similar to this appearing in the location where the tag was placed:
If you wish to edit the contents of the banner, override the
templates/allauth_sniperlinks/banner.htmlfile in your own templates directory structure. -
A list of all unverified emails along with sniper links and images for the appropriate webmail provider, if appropriate, are injected into the CONTEXT of all pages. You can access this via the "sniperlinks" context variable, which will contain a dictionary of unverified emails for the authenticated user, keyed by email address, with each value represented as another dictionary with keys of "link" with the URL for the sniper link and "img" with the path to the image for their webmail provider's icon.
For example, in a template, accesssing the
{{sniperlinks}}context variable will provide something like this:{ 'test@gmail.com' : { 'link': 'https://mail.google.com/mail/u/0/#search/from%3A%40mydomain.com%3E+in%3Aanywhere', 'img': '/static/allauth_sniperlinks/provider_icons/Gsuite.svg', } }Note that the context variable is cached so that each page display does not require a database query. The cache entry for the user is invalidated whenever a new email address for the user is added or an existing one is changed in some way.
Settings
-
ALLAUTH_SNIPERLINKS_VERIFICATION_SENDER Set the email used to send verification senders. This is used when creating sniper links, see features section above for an example.
Defaults to
settings.DEFAULT_FROM_EMAIL. -
ALLAUTH_SNIPERLINKS_BANNER_ONLY_PRIMARY If True, then the
unverified_email_bannertemplate tag will only create a banner for an unverified address if it is the primary one. Otherwise, multiple banners may appear for each unverified email address associated with the account.Defaults to
True.
Management Commands
-
python manage.py clear_sniperlink_cacheThis command will clear out the sniperlink cache used by the context processor. It does this by incrementing a version number used for all sniperlink cache entries. Otherwise, all sniperlink cache entries for users have a timeout of 5 minutes.This may be useful if you change the ALLAUTH_SNIPERLINKS_BANNER_ONLY_PRIMARY setting and don't want to wait for the 5 minute timeout for the banners to update.
Metadata
Release files for django-allauth-sniperlinks 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-allauth-sniperlinks-0.3.tar.gz | 50.4 kB | Without provenance | Details for django-allauth-sniperlinks-0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_allauth_sniperlinks-0.3-py3-none-any.whl | Python 3 | none | any | Details for django_allauth_sniperlinks-0.3-py3-none-any.whl |
Total release size: 108.8 kB
Release files / django-allauth-sniperlinks-0.3.tar.gz
| Download URL | django-allauth-sniperlinks-0.3.tar.gz |
|---|---|
| Size | 50.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5295175edd075506d54b589fab15ab030ce195f8145eff429e7733a4ec758f71
|
|
BLAKE2b-256 checksum How to use checksums |
6625bb49815c9a7d65dde2722c6da18fe0e3101bda32fbd23bdb629f68afc85d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.15
|
Release files / django_allauth_sniperlinks-0.3-py3-none-any.whl
| Download URL | django_allauth_sniperlinks-0.3-py3-none-any.whl |
|---|---|
| Size | 58.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
944b23497a35bd2f971f16fb9e0c1077c7ab16dd6e02d31105cc29164934512f
|
|
BLAKE2b-256 checksum How to use checksums |
437aeba8a4c77f8ef45f309452152e2f7b302817891f44530644787ee4124c7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.15
|
Security for django-allauth-sniperlinks 0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.