Python for Entrepreneurs Transcripts
Chapter: User accounts and identity
Lecture: Demo: Indicating the signed in status
Login or
purchase this course
to watch this video and the rest of the course contents.
0:02
So you can see, here I am on my account page and we can only access that if you are logged in,
0:09
However, the main navigation does not indicate whether or not I am logged in
0:13
and of course we want that to change, so let's take the information that our controllers know, about the user, whether or not they are logged in
0:20
and let's push that on to the master view here. So we come down to, let's get this out of our way, don't need that,
0:27
come down here to our shared layout, and not far down, we have our navigation bit, about sign in and register.
0:34
And let's go over here and do a conditional so we'll say tal:condition, now we actually already have access to the controller,
0:43
now the reason that we have access to it is we have this base controller and we are guaranteed every single request that runs through Python
0:51
is running through that base controller in some way or another. So it's doing good stuff for us here, so what we are going to do is
0:58
we say if it's not the case that the view remember that's Pyramid's terminology
1:02
for the view...the controller, is the way we structured it and what did we call this, we called this like logged_in_user or something like that,
1:10
logged_in_user_id, as a property. So if it's not the case that there is a valid logged in user,
1:16
then we want to show a sign in and we also want to show register. but we're going to have an alternate version for when you are signed in.
1:23
This is going to be log out, let's do account here, and maybe just like this,
1:30
and this will be log out, I don't think we've written log out yet but we're going to. OK, so if the user is signed in, you should see this,
1:43
if the user is not signed in, you should see the sign in features. So, let's go over here and refresh this, remember, we're signed in right now
1:50
boom, sign in, log out, but if we open it in a private browsing session, sign in / register, if we do sign in / register, then we are signed in.
1:58
Beautiful, right. Check that the account works, log out, it's not found yet, let's go write that.