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
0:04 and we can only access that if you are logged in,
0:08 However, the main navigation does not indicate whether or not I am logged in
0:12 and of course we want that to change, so let's take the information that our controllers know,
0:17 about the user, whether or not they are logged in
0:19 and let's push that on to the master view here.
0:22 So we come down to, let's get this out of our way, don't need that,
0:26 come down here to our shared layout, and not far down,
0:30 we have our navigation bit, about sign in and register.
0:33 And let's go over here and do a conditional so we'll say tal:condition,
0:37 now we actually already have access to the controller,
0:42 now the reason that we have access to it is we have this base controller
0:47 and we are guaranteed every single request that runs through Python
0:50 is running through that base controller in some way or another.
0:54 So it's doing good stuff for us here, so what we are going to do is
0:57 we say if it's not the case that the view remember that's Pyramid's terminology
1:01 for the view...the controller, is the way we structured it and what did we call this,
1:06 we called this like logged_in_user or something like that,
1:09 logged_in_user_id, as a property.
1:11 So if it's not the case that there is a valid logged in user,
1:15 then we want to show a sign in and we also want to show register.
1:19 but we're going to have an alternate version for when you are signed in.
1:22 This is going to be log out, let's do account here, and maybe just like this,
1:29 and this will be log out, I don't think we've written log out yet but we're going to.
1:38 OK, so if the user is signed in, you should see this,
1:42 if the user is not signed in, you should see the sign in features.
1:45 So, let's go over here and refresh this, remember, we're signed in right now
1:49 boom, sign in, log out, but if we open it in a private browsing session,
1:53 sign in / register, if we do sign in / register, then we are signed in.
1:57 Beautiful, right.
1:59 Check that the account works, log out, it's not found yet, let's go write that.