335

How to change the email verification link in allauth

<h3>Question</h3>

I'm using allauth in my django application. Once the user is created it sends an email with the link like this http://localhost:8001/account/confirm-email/asdfafsd/

However, I want the link to be http://localhost:8001/verifyEmail/asdfafsd since I am using angular on the front end.

I can't figure out where to change this link?


<h3>Answer1:</h3>

Add to urls.py custom URL:

url(r"^verifyEmail/(?P<key>\w+)/$", allauth.accounts.views.confirm_email, name="my_confirm_email")

And edit email-template to use 'my_confirm_email' url:

http://django-allauth.readthedocs.org/en/latest/advanced.html#sending-e-mail


<h3>Answer2:</h3>
<ol><li>Override the template by creating a same named file. For django-allauth: templates/account/email_confirmation_message.txt</li> <li>

create a sample custom tag and include in any of your app, i.e for example app userprofile in userprofile/templatetags/userprofile.py

</li> <li>

in userprofile.pycode can be like

from django import template from django.template.defaultfilters import stringfilter register = template.Library() @register.simple_tag(name="make_confirm_url", takes_context=True) def make_confirm_url(context): activate_url = context.get('activate_url') slice_idx = activate_url.find('account') return ''.join(['http://', context.get('current_site').domain, '/',activate_url[slice_idx:]]) </li> <li>

email_confirmation_message.txt can be like

{% load userprofile %}{% make_confirm_url as the_link %} {% load account %}{% user_display user as user_display %}{% load i18n %} {% autoescape off %}{% blocktrans with site_name=current_site.namesite_domain=current_site.domain %} Hello from {{ site_name }}! You're receiving this e-mail because user {{ user_display }} has given yours as an e-mail address to connect their account. To confirm this is correct, go to {{the_link}} {% endblocktrans %}{% endautoescape %} {% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Thank you from {{ site_name }} Dev Team ! {{ site_domain }}{% endblocktrans %} </li> <li>

In the above code the domain is fetched from the django_sites Model You can include you logics and write a route accordingly in frontend framework (like angular). Thanks

</li> </ol>

来源:https://stackoverflow.com/questions/28412226/how-to-change-the-email-verification-link-in-allauth

Recommend

  • How can I run loopback application on port 80
  • Getting width of the Notification-Center inside Today-Extension
  • How to encode Java files in UTF-8 using Apache Ant?
  • most efficient way to write data into a file
  • Angular UI-Router: Multiple URLs to single state
  • Merge Maps in Golang
  • Google Cloud Functions: Project layout for Github publishing
  • How can I convert a hex string to a u8 slice?
  • Failed resolution of: Landroid/support/v7/widget/ListViewCompat;
  • Getting issue on terminal command while creating opencv2.framework
  • How do you run a string as code? [duplicate]
  • Adjust View for keyboard appears when switching UITextField (Swift)
  • Python multiprocessing using a lock or manager list for Pool workers accessing a global list variabl
  • Grid View and media player on Click
  • Pass data from page to page safely
  • On Woocommerce order complete, activate woosensei course
  • Streaming huge json with Akka Stream
  • Ellipsis directive with title
  • When to use MSAL AcquireTokenSilentAsync
  • DocuSign API Replace template document but keep fields
  • Spring Cloud Config - Multiple Composite Repositories?
  • How to run Daphne Server (Django Channels) & workers in the background?
  • didSelectItemAtIndexPath of UICollectionView inside of a UIScrollView is not getting called
  • Draw 9 patch dotted /dashed line on Android
  • Auto send email based on the time and email address in database
  • Google TV VideoView playing YouTube rtsp videos
  • Why do you need 2 Javascript files for cross-platform Cordova plugin?
  • How to define a custom accuracy in Keras to ignore samples with a particular gold label?
  • Controller or RestController
  • select an input by value?
  • Ember.js + JQuery-UI Tooltip - Tooltip does not reflect the model / controller changes
  • concise way of flattening multiindex columns
  • Content-Type alternative in MQTT
  • How to turn off notice reporting in xampp?
  • Can a PHP script be scheduled to run at a specific time or after a specific amount of time has expir
  • how to run ejabberd with Erlang on Heroku?
  • Call Microservice from another Microservice within Docker