-
Notifications
You must be signed in to change notification settings - Fork 0
Ability to logout from frontend #186
Comments
Logging out can be achieved by setting the |
Depends on #49 |
The PR for #49 has just been opened, but here is how logging out was implemented assuming that it will be merged in a similar way to how it functions now. Because we have context providers toggling the login state required importing the Because the access token is stored in a cookie, if a user logged out they would still be able to navigate to the AppView without having to log in again. In order to fix this problem the cookie that contains the access token that allows users to access the AppView needs to be deleted when a user logs out. This was easy to implement as Both of these were implemented in a function that is passed to the ItemAppBarActions component created in #49. Here is how that implementation works. handleLogout function const setLogin = useLoginSetter();
const setToken = useTokenSetter();
const [cookies, removeCookie] = useCookies(["csrf_refresh_token"]);
const handleLogout = () => {
setLogin(false);
removeCookie(["csrf_refresh_token"])
} ItemAppBarActions implementation <ItemAppBarActions
tooltipTitle={"Logout"}
onClick={() => handleLogout()}
icon={<LogoutIcon />}
/> |
Now that actions are passable to the ItemTableAppbar logout functionality is available. It uses the same functions as before, which I will list again below.
const setLogin = useLoginSetter();
const [cookies, removeCookie] = useCookies(["csrf_refresh_token"]);
const handleLogout = () => {
setLogin(false);
removeCookie(["csrf_refresh_token"])
} This function does two things:
These work together to make it so a user has to log back in after they click the logout button. |
Closed in #226 |
Can't do it. Should be able to.
The text was updated successfully, but these errors were encountered: