Great. So we know the flow is completed. You can actually see, um, you can actually see here we have our, uh, DS and DSR. These are our session refreshed tokens here. So, um, this is already, this is already, we already have authentication. Um, and, um, and, uh, we're not doing, we're not actually sending this with any of the requests yet or anything like that. We're still going to code all that. But, uh, pretty straightforward. But I mean, you could see in maybe, you know, a few minutes we added, uh, we added a sign in page and you can just, you can always view that by just going to, uh, local host 3000 dash sign in, you can see that sign in page. Now, if you go back to the dashboard here, you'll see that it still says log in. The reason why is because we have encoded, we haven't used the is authenticated react hook that can determine, and you can embed these in anywhere, in any react, um, in any part of your react application to check whether or not if you want to perform some logic to check whether or not the, uh, the user's authenticated. So, um, the first step we want to do is, uh, we want to actually allow the user to log out. We want to happen. Not only do we want to say log out, we want to actually have that functionality. Um, so let's go to nav bar, which is under, uh, which is under components editor nav bar dot JSX. And as you can see here, um, I have a few things already coded out that aren't being used. So we have a log out user and log in user callback function. Um, we have a log out pop over in a login pop over the only difference between these two is that the color is different. One says log out once it's log in. You'll see those working in a minute. And then on click it points to a different function. Now, the reason why that is, is because when we log in, all we want to do is go back to the sign in page. But when we log out, we want to also go back to the sign in page, but we want to first log out and we do that with the discovestigate. So what you want to do is you want to import, use disco. From. He's go react to stk. Hopefully this is making sense to you guys. I'm just going to import this. And then this is how we're actually going to, this is, this is, uh, this, our login there's our, sorry, our logout function is baked as part of, is baked in a part of this use disco. So if we go to con, if we create a const logout and initialize it with. Use disco. Now we have a log at, we have an eight. We have a logout function, which we can use. We can, uh, we can use within a wait to actually log out the user and invalidate their seconds. Um, so I can explain a little bit more later on if we have time about how this works and how the technology can work with the dots, but for now, um, I'm just going to show you guys, so under logout using the, it's the same as login. The user, um, instead of it being exactly the same, we're just going to have a try catch and the try catch is going to log out the user. So, you know, we're going, we can just say console log error. If there is an error, but if there's no error, all I have to do is say, Oh, wait, logout. So now when the user, you know, when, when the user clicks the logout button, which we haven't actually embedded yet, but when the user clicks out the lock, and clicks logout button, it's going to run this real quick and just make sure to invalidate the session. You can see it's an async function here that will, um, that will make sure that the session got us invalidated. Um, and so, uh, so now you can see here we have a logout and login popover. These two I created here. What we want to do is right now, if you go scroll down to where the popover is defined here, login popover, you see, there's the content. It's only ever showing login. Right? Even if I'm logged in or logged out, it doesn't matter, and there's no logic behind that. So the way that we're going to do this is underneath, uh, underneath, uh, div class same, uh, avatar we are going to, uh, we're going to actually use one of our is authenticated react hooks and have a separate logic to either show the login or logout popover, depending on the user is authenticated. You'll see what that looks like in a second. First thing we got to do is underneath here. You want to actually, uh, actually before that, we want to import something called new session. This is how we're going to associate, uh, and, and get session information, current session information.
Comments