Anvil: Web Apps with Nothing but Python Transcripts
Chapter: User management and authentication
Lecture: Logging out

Login or purchase this course to watch this video and the rest of the course contents.
0:00 We saw we can register and we saw we can drive the user interface based on whether or not there is a user
0:07 even from remembering us from session to session, right? So if I run this now we'll see that account and logout are shown
0:14 but that login and register are not. However, we probably want to let them log out at some point, right?
0:21 So let's go do that, that turns out to be super, super easy. So when you go down here and you click this you see Anvil.users.logout. Not too hard, huh?
0:33 And we also want to go back home and set this user state. Okay, so we're going to go do those three things. I'm going to log out
0:43 and then we want to set this to be None because we've logged them out and then we're going to go home that's going to trigger a refresh
0:51 of potentially that home screen and show the anonymous view. if you're on the home screen, of course it's just going to toggle that
0:57 but if you were maybe somewhere else like in your account page got to take 'em somewhere that's valid and home is always valid. Let's run that.
1:04 All right, we're logged in, as you can see right here. I click logout, it should change this menu. Should re-navigate us home
1:11 which is going to reload this to home anonymous view. Let's give it a shot, here we go. Again, the cell. All right, let's try it one more time.
1:21 Well, our logout worked. We just weren't able to update.


Talk Python's Mastodon Michael Kennedy's Mastodon