Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9215603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:14:24+00:00 2026-06-18T02:14:24+00:00

I authenticate the user in this view: def note_edit_auth(request): if request.method == ‘POST’: form

  • 0

I authenticate the user in this view:

def note_edit_auth(request):
        if request.method == 'POST':
                form = EditAuthForm(request.POST)
                if form.is_valid():
                        email = form.cleaned_data['email']
                        password = form.cleaned_data['password']
                        user = auth.authenticate(username = email, password = password)

                        if user and user.is_authenticated():
                                request.session['email'] = email
                                request.session['password'] = password
                                request.session['user'] = user
                                return HttpResponseRedirect('/note_edit')
                        else:
                                return HttpResponse('User or password is either incorrect or does not exist.')

And it works. user is indeed authenticated. So then I try to access request.user from another view where the above view redirects to like this:

def note_edit(request):
        if request.method == 'POST' and request.user.is_authenticated():
                form_edit = EditForm(request.POST)
                user = request.session['email']
                auth.logout(request)
                return HttpResponse('Done!')
        elif request.method == 'GET' and request.user.is_authenticated():
                form_edit = EditForm(irrelevantfoofoo)
        else:
                return HttpResponse('User not authenticated.')
        return render_to_response('editnote.htm', {'form': form_edit}, context_instance = RequestContext(request))

And suddenly I get the response that user is not authenticated. When I tried printing request.user to console it is showing as AnonymousUser. And I kid you not this was working fine last night. Today I wake up, make some changes and it starts misbehaving. I revert all changes and it still misbehaves.

Why is this happening and how do I fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:14:26+00:00Added an answer on June 18, 2026 at 2:14 am

    auth.authenticate() just checks if the provided user credentials are valid.
    To actually log the user in you have to use login().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my login view: def sign_in(request): if request.method == 'POST': form = LoginForm(request.POST)
This view function: @login_required def dashboard(request): from myproject.myapp.models import UserProfile k = UserProfile.objects.get( user=request.user.pk
Client access the login view, //user is properly set here user = auth.authenticate(username=email, password=password)
i've a probelem with the request.user.is_authenticated() this the view. from django.http import HttpResponseRedirect from
I'm trying to authenticate user accounts in Windows Phone. I found this C# library
I have a controller like this : @Secured(['ROLE_USER','IS_AUTHENTICATED_FULLY']) def userprofile(){ def user = User.get(springSecurityService.principal.id)
I'm trying to make a user login view, and It keep failing. This is
I use the devise's authenticate_user! method in a controller. This is working fine when
In my base.html I placed this: {% if user.is_authenticated %} you are logged in!
I want authenticate user in my android app through google login and then dispaly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.