Answer the question
In order to leave comments, you need to log in
How to save user but user.is_authenticate must be false?
In my web application, I send an email to the user to activate his account and when I redirect him to the confirmation page from the email, the menu items that shouldn't be displayed are shown because he is authenticating without being logged in though such should not be
the Views function to activate the user:
def activate_user_account(request, signed_user=None):
user, signature = decoder(request, signed_user)
if user and signature:
user.email_confirm = True
user.save()
return render(request, 'email_verify_done.html', {'user': user})
{% if user.is_active %} {% if user.is_authenticated %}
<p class="text-center">{% trans 'Your email address confirmed' %}</p>
{% else %}
<p class="text-center">
{% trans 'You can' %}
<a href="{% url 'users:login' %}"> {% trans 'log in now' %}</a>
{% trans 'or do it in your mobile app' %}
</p>
{% endif %} {% else %}
<p>{% trans "Something went wrong." %}</p>
{% endif %}
Answer the question
In order to leave comments, you need to log in
Solved the problem like this:
{% if user.is_active %}
{% if request.user.is_authenticated %}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question