I have used Django's built-in password reset functionality. everything is working fine but when I open the password reset link from Gmail browser redirects me to Django's built-in "password_reset_confime " template instead of my custom template
I don't know where I have done mistake in rendering custom template please help me to do that its really appreciated
usrl.py Code
app_name="accounts"
urlpatterns=[
path('password_reset/',auth_views.PasswordResetView.as_view( template_name='password_reset.html', success_url=reverse_lazy('accounts:password_reset_done')),name='password_reset'),
path('password_reset_done/', auth_views.PasswordResetDoneView.as_view(template_name='password_reset_done.html'), name='password_reset_done'),
path('password_reset_confirm/<uidb64>/<token>/',auth_views.PasswordResetConfirmView.as_view(template_name='password_reset_confirm.html',success_url=reverse_lazy('accounts:password_reset_complete')),name='password_reset_confirm.html'),
path('password_reset_complete/', auth_views.PasswordResetCompleteView.as_view(template_name='password_reset_complete.html'), name='password_reset_complete'),
]
And I also want to implement a feature while entering an email id into the input field, I want to check if the user's entered email exists or not, if do not exist I want to show an error message "this email id is not existed"
please help me to implement this feature and provide a solution for rendering my custom password_reset_confirm.html and password_reset_complete.html pages
Related
I'm setting the authentication process in my Django project.
In my password_reset_email.html I have set the following code:
Someone requested a password reset for the account associated with the email {{email}}.
If you haven't changed any passwords, I will ignore this email.
Follow the link in case you proceed:
{{protocol}}://{{domain}}{% url 'password_reset_confirm' uidb64=uid token=token %}
But when I send the e-mail, the hyperlink does not work; there appears only the text of the link.
How could get a working hyperlink?
The relevant docs for you would be PasswordResetView.html_email_template_name:
html_email_template_name: The full name of a template to use for generating a text/html multipart email with the password reset link. By default, HTML email is not sent.
With this, your code could look something like this:
path(
'accounts/password_reset/',
PasswordResetView.as_view(
html_email_template_name='my_email_template.html')),
See this answer of a very similar question.
I am working with django and react and developing a multi tenant application where each subdomain in django is a different company. Using rest framework.
At user registration(company wise user) a confirmation email is send to each user to activate their account.
The email send to users are in the format of
http://company_code.localhost.com:8000/rest-auth/account-confirm-email/key
subdomain wise. After some search i came to know this goes from allauth, send_confirmation_message.text file and in the form of {{activate_url}}
for activating the account from react what i did was changed the default 'send_confirmation_message.txt' file of allauth as :
'http://localhost:3000/verify-email?key={{key}}' -- react
now i automatically filter my key from url on react and post to backend, and activate the account,
the manual part still is getting company code from the url which django send in the email.
Again i have read about template filter tag but can not use.
So how can i use filter on {{activate_url}} which is
http://company_code.localhost.com:8000/rest-auth/account-confirm-email/key
to get my company_code and send to react in the form of url.
Getting company_code is important as users are company wise and react should post to a specific company.
Or My approach is wrong and should try something other ?
Thanks
I made it work..
{% blocktrans %} in email_confirmation_message.txt was not allowing me to apply any filer on {{activate_url}} or add any new block.
I removed it and changed the url which user receive in email for activating the account.
The new url is :
http://front-end.com/verify-email/?id={{key}}&id1={{activate_url|slice:"7:12"}}
subdomain is always of 5 character,in my case.
and it takes me to my front end, automatically activate the account on componentDidMount and redirect to login.
ps: blocktrans will not allow to apply any filter, add new block.
still don't know what blocktrans is, if anyone can provide detail.
Thanks
My have a issue. I want dashboard panel access directly without admin login page.
1
How i can solve?
Thanks.
That will require a lot of work to do, so maybe try to think out of the box , instead of removing the login requirement why not just force login without any user input
like so:
<script>
$(document).ready(function() {
function Login(){
$("#input-username").val('YOUR ADMIN USERNAME')
$("#input-password").val('YOUR ADMIN PASSWORD')
$("form").submit()
}
Login();
});
</script>
Since you are giving free access to your admin panel i assume that you do not care about user login and password and might as well show them in the code.
I was trying to redirect the user to an external URL(such as https://stockoverflow.com) and that URL contains a login form.
I would like to fill in the username and password column for the user.
As if there's auto-complete function.
I can't figure it out by using redirect or HttpResponseRedirect.
Could someone enlight me or give me some directions?
You can pass the email and hashed password via GET parameter, then get them in destination URL and parse them into your form. But this approach is not recommended at all.
I am using allauth to provide registration and login in my django site. Everything else seems to be working fine other than that I am having problems to redirect the person to the current page after login.
I have a page where I have some interview questions and a typical url for it would be like
/questions/?company=google
This page contains a list of questions for the company google, but to view the answer the person needs to login. The answers are displayed in a dropdown box. However when the user clicks on login a request is sent to the login page as follows
/login/?next=/questions/
And the get parameter which was actually there in my actual page is not sent because of the & in my url. How can I solve this problem. It does not look nice that the person is redirected to a different page from where he/she tried to login.
I know sending the next parameter as a GET variable is not the solution, but is there a way I can send the redirect link as a POST variable from the template.
I tried another thing, in my view that displays the questions list. I set session variables which contains the url of the current link . If a user clicks on login, in my login view I check for this particular session variable. If it is set then I redirect to that page.
However the session variable is not received in the login view, I am not sure but I think the session is reset when the user goes to the login view.
Any suggestions are appreciated.
Have you tried
next = request.get_full_path()
This will return correct path with all queries ( see docs ) , you can then pass it as GET param to redirect url e.g.
full_path = request.get_full_path()
return HttpResponseRedirect('%s?next=%s' % (reverse('login'), full_path))
You should encode the URL-parameter in this case. You want to send a variable like /questions/?company=google, but as you mentioned the ?, = (amongst others) characters are special ones. It has a special meaning when embedded in the URL. If you encode the variable with URL encoding, it becomes %2Fquestions%2F%3Fcompany%3Dgoogle. If you assign that to the parameter next, the URL becomes: /login/?next=%2Fquestions%2F%3Fcompany%3Dgoogle. This should redirect to the correct place on login.