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

User should be logged in automatically after clicking email confirmation link #130

ghost opened this issue Jun 9, 2014 · 8 comments


Copy link

@ghost ghost commented Jun 9, 2014

Please add ability to auto login after email confirmation if user is not authenticated and email was confirmed well...

Copy link

@ghost ghost commented Jun 18, 2014

@brosner , what do you think about this feature?.. Is any pitfalls there?...

Copy link

@avelis avelis commented Jun 30, 2014


Copy link

@mattions mattions commented Jul 2, 2014

+1 here as well. Got a bunch of user requesting why they have to log in twice

Copy link

@ghost ghost commented Jul 3, 2014

I did not tested it yet but this is my custom code:

def confirm_email_view(request, key):

    queryset = EmailConfirmation.objects.all()
    queryset = queryset.select_related("email_address__user")
        confirmation = queryset.get(key=key.lower())
    except EmailConfirmation.DoesNotExist:
        raise Http404()
    if not confirmation.key_expired() and not confirmation.email_address.verified:
        email_address = confirmation.email_address
        email_address.verified = True
        signals.email_confirmed.send(sender=confirmation.__class__, email_address=email_address)
        user = email_address.user
        user.is_active = True
        if request.user.is_authenticated():
            redirect_url = reverse('user', args=[str(request.user.username)])
            user.backend = 'django.contrib.auth.backends.ModelBackend'
            login(request, user)
            redirect_url = reverse("post-register")
            "Ты успешно подтвердил(-а) {email}.".format(**{"email":})
        redirect_url = "/"
    return redirect(redirect_url)
Copy link

@jtauber jtauber commented Jul 8, 2014

👍 from me on the idea. @lorddaedra's code seems more complex than what is necessary.

Copy link

@paltman paltman commented Jul 8, 2014


@paltman paltman changed the title Auto login after email confirmation if user is not authenticated User should be logged in automatically after clicking email confirmation link Jul 8, 2014
@brosner brosner modified the milestones: 1.0, 1.1 Sep 18, 2014
Copy link

@k4ml k4ml commented Sep 7, 2015

There should be a flag on this, since some people probably want to force user to login after verifying the email. Similar to django-allauth settings - ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION.

Pasting the notes from django-allauth here, just in case it also applied:-

The default behaviour is not log users in and to redirect them to ACCOUNT_EMAIL_CONFIRMATION_ANONYMOUS_REDIRECT_URL.

By changing this setting to True, users will automatically be logged in once they confirm their email address. Note however that this only works when confirming the email address immediately after signing up, assuming users didn’t close their browser or used some sort of private browsing mode.

Copy link

@avelis avelis commented Oct 18, 2016

🎉 @brosner Thanks for contributing this feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.