Building Data-Driven Web Apps with Pyramid and SQLAlchemy Transcripts
Chapter: User input and HTML forms
Lecture: Logging out
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Let's just round out this demo part of this chapter by closing out what we're doing with the users. We've done all of these things
0:08
and that let us explore working with forms. Let's go ahead and add logout. Technically this has nothing to do with forms
0:14
but we have been doing this user stuff so let's just finish that up real quick. So I already have this /account/logout route
0:23
and we're going to come over to here and we're just going to add another little action method here. We'll say logout.
0:34
You'll see we don't need a renderer and we don't need to set the get. And we're going to return. When somebody logs out
0:44
we got to figure out where do they go. Let's return them to http found at just /, okay? How do we log them out? Well remember the way they're logged in
0:53
is they have a cookie that they're passing back and forth. All we're going to do is delete that cookie their session is gone.
1:00
So we have cookie_auth and it has a logout function. And we give it the request, that's it. Let's look really quick at that.
1:09
It just said to call back to say delete this which goes to the response, deletes the cookie. All right, well that should be pretty easy.
1:16
Let's try logging out. Can see right now we're logged in. We can go to our account page to click this. Boom, login register.
1:27
I try to go back to account, can't go there. We're logged out. We got to go log in first. Perfect, huh? All right, well that rounds out the user stuff.