What's the value of request.session['user'] when user is not logged in?

My guess is it's an instance of AnonymousUser.

2016-04-20 11:43 GMT-03:00 Neto <[email protected]>:
> Hi,
>
> I have a middleware that checks whether the user is logged in.
>
> class Check(object):
>
>     """
>         Check
>     """
>
>     @staticmethod
>     def process_request(request):
>
>         def is_authenticated_user():
>
>             try:
>                 request.session['user']
>             except KeyError:
>                 return redirect(reverse('mysite:login'))
>
>
>         is_authenticated_user()
>
>
>
> Why it does not works? How to solve?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7a9effe3-9fd3-42ff-bfd3-5ab7ea03030e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADut3oA0ibHqEU6HbPC8zdB7UYRJju%2BZv%3D8Y82U_30NFRQmHoQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to