ADD logout functionality to SecurityConfig and Topbar
This commit is contained in:
@@ -13,6 +13,7 @@ type props = {
|
||||
const Topbar = ({sidebarToggled, setSidebarToggled, user, className}: props) => {
|
||||
const apiUrl = import.meta.env.VITE_API_URL;
|
||||
const loginUrl = `${apiUrl}/oauth2/authorization/google`;
|
||||
const logoutUrl = `${apiUrl}/api/v1/auth/logout`;
|
||||
|
||||
return (
|
||||
<div className={clsx(className, "flex justify-between")}>
|
||||
@@ -20,10 +21,24 @@ const Topbar = ({sidebarToggled, setSidebarToggled, user, className}: props) =>
|
||||
{sidebarToggled ? <Menu size={24}/> : <X size={24}/>}
|
||||
</MenuButton>
|
||||
|
||||
<MenuButton className={"w-40 text-gray-600"}
|
||||
onClick={() => globalThis.location.href = loginUrl}>
|
||||
{ user ? user.name : "Login" }
|
||||
</MenuButton>
|
||||
{ user ? (
|
||||
<div>
|
||||
<MenuButton className={"w-40 text-gray-600"}>
|
||||
{user.name}
|
||||
</MenuButton>
|
||||
<MenuButton className={"w-20 text-gray-600"}
|
||||
onClick={() => globalThis.location.href = logoutUrl}>
|
||||
Logout
|
||||
</MenuButton>
|
||||
</div>
|
||||
) :
|
||||
(
|
||||
<MenuButton className={"w-20 text-gray-600"}
|
||||
onClick={() => globalThis.location.href = loginUrl}>
|
||||
Login
|
||||
</MenuButton>
|
||||
)};
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user