Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to customize the url in password_reset_confirm.html #58

Closed
hcgaron opened this issue May 6, 2020 · 4 comments
Closed

How to customize the url in password_reset_confirm.html #58

hcgaron opened this issue May 6, 2020 · 4 comments

Comments

@hcgaron
Copy link

hcgaron commented May 6, 2020

I appreciate you forking and maintaining this project!

I have my api hosted at a different location (completely different url) than my frontend. When I send the password reset confirm email I'd like to have the url point to one on my front end which can be parsed and displayed there. I can't figure out where the email content is generated.

I see this line

# this url is used to generate email content url(r'password-reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', TemplateView.as_view(template_name="password_reset_confirm.html"), name='password_reset_confirm'),

so I understand that is where the email url is being generated from. I can't figure out where to customize this email. I tried searching but forked repos aren't able to search code. I tried searching the original repo but still couldn't find it.

Thanks!

@iMerica
Copy link
Owner

iMerica commented May 7, 2020

Override PASSWORD_RESET_SERIALIZER, with your own serializer.

REST_AUTH_SERIALIZERS = {
    'PASSWORD_RESET_SERIALIZER': 'path.to.your.CustomPasswordSerializer'
}

make this serializer inherit from the base and add your own custom save method that handles the custom logic.

from dj_rest_auth.registration.serializers import RegisterSerializer

class CustomRegistrationSerializer(RegisterSerializer):
  def save(self, request):
    #  get whatever data you need
    verify_url = ' <add your own custom url here>'
    # send the email using this new verify url

See the source code for RegisterSerializer here

@mohmyo
Copy link
Contributor

mohmyo commented May 10, 2020

I have been through these questions before, the folks there did a pretty good job to make me understand the full cycle of this, also I have added the code snippet I used in my project.

Please read and check out my past issues
How to send customized email template for password reset endpoint?
The generated password reset token is not long enough and always having a fixed length

@iMerica
Copy link
Owner

iMerica commented May 19, 2020

Closing this since we now have lots of answers.

@iMerica iMerica closed this as completed May 19, 2020
@ghost
Copy link

ghost commented Sep 13, 2020

the code can custom password_reset_confirm url in email ,try

from django.contrib.auth import views as auth_views

 urlpatterns += [
    path('password_reset_you_want/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(),
         name='password_reset_confirm'),  
]

https://stackoverflow.com/questions/28423959/is-there-a-way-to-change-the-password-reset-confirm-link-sent-by-django

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants