Django-AllAuth ACCOUNT_CONFIRM_EMAIL_ON_GET confusion - django

I'm a little bit confused by the configuration variable ACCOUNT_CONFIRM_EMAIL_ON_GET. (docs)
If a user clicks on an activation link in an email, wouldn't the request have to be a get request? (Surely I'm wrong or missing something).
From my testing, if I leave ACCOUNT_CONFIRM_EMAIL_ON_GET set to False, when I click on the activation link from my email my account does not get activated. What am I missing here?

When a user is registered an url to confirm the e-mail address is generated. Eg:
http://www.example.com/accounts/confirm-email/iq4ma0qw6fqazui7ilwd4b3vftg/
With ACCOUNT_CONFIRM_EMAIL_ON_GET set to True the user will confirm the e-mail just by clicking the link. This happens because by clicking on the link, he will request the url (GET) and therefore, allauth will mark the e-mail address as confirmed because a GET for this url was received.
With ACCOUNT_CONFIRM_EMAIL_ON_GET set to False, when the user clicks on the link, a page will be loaded where there will be a button "Confirm e-mail address" or something like this. Then the user has to click on that button that will generate a POST request that will confirm the e-mail. This happens because allauth will mark the e-mail address as confirmed only on POST and not on GET requests to the e-mail confirmation url.

If you take a look at the source, you can see that the arguments passed to the view from the URL will be redirected to the post() method, meaning the user will not see a confirmation screen.
https://github.com/pennersr/django-allauth/blob/master/allauth/account/views.py#L213

Related

Django authentication process, how to render the template of email?

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.

Django redirection after successful login

Is it possible that after successful login first redirect to a new page and not to that url witch is in the next parameter (ex. http://localhost:8000/ro/login/?next=/ro/exam/3/). So what I exactly want is after a successful login first redirect to that url what I provided in LOGIN_REDIRECT_URL, and also I want to keep somehow the next url ( http://localhost:8000/ro/login/?next=/ro/exam/3/), because after the user clicks somewhere I want to redirect him to the target.
Ciao, why don't you redirect the user in LOGIN_REDIRECT_URL on login button click, and then on another user action send him to ( http://localhost:8000/ro/login/?next=/ro/exam/3/) (stored somewhere as a string) ?

OpenCart: 2Checout Logged users gets logged out on success page

I have 2checkout return customers to the URL
http://store.com/index.php?route=checkout/success. Which is correct? Anyway, 2checkout sent me to the homepage after successful payment and showing as a visitor with empty cart., when click on continue button showing logged in and same cart items in cart.and
opencart didn't record the order nor did i receive any order confirmation via email.(Required)
The customer received an order confirmation but product's option (if any) is not shown. Please help!!
Thanks in advance...

how to send a mail from plone site

Can anyone tell me how to send a mail from plone site. What i m trying to do is(will list out my points)
i have a template page(html page) called contact us.In which the user can enter his/her name, email id, address, etc. After entering the things he have to submit it to a particular mail id.
I create a .py file for getting those values from contact us html page.
After getting the values, it should be mailed to a particular mail id.
my html page somewhat looks like like:
<html>
<form action="mailto" method = "post" name="mailto">
Name :<input type="text" name="fname" />
address :<input type="text" name="address"/>
</form>
</html>
mailto.py
class MailTo(BrowserView)
def __init__(self,context,request):
self.context = context
self.request = request
def registerdetail(self):
mailhost = self.context.MailHost
form= self.request.form
name=form.get('fname')
address=form.get('address')
mto = 'xxxx#gmail.com'
msg="""
Name:%s
Address:%s
""" %(name,address)
mailhost.send(messageText=msg, mto=mto, mfrom='yyy#yahoo.com')
return self.sucesspage()
I tested it directly by giving my own mailid in "mto=gsgfsf#gmail.com" but i didnit receive any mail. can anyone tell whats wrong with my things.
Thanks in advance
You'll find it much easier to simply use PloneFormGen (a popular add-on for Plone) to build your form. You can make the email destination for the form configurable by following the instructions at: http://developer.plone.org/reference_manuals/active/ploneformgen/select_mail.html
According to what you say on the mailing lists, your problem is that you installed the developer tool Products.PrintingMailHost.
With that installed emails are printed to the console instead of being sent. This is so you can test sending emails without actually having to send emails.
Verify you have configured Plone to send mail first. In Site Setup -> Mail, enter your mail server information and click Save and Send test e-mail.
Then using MailHost in Python should work (unless you are using Products.PrintingMailHost which prints email instead of sending it.)

How to redirect to page which has GET parameters after login using the {{next}} variable in django

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.