Replace basic auth with cookie authentication (#440)

* Add logout functionality and button
* Make session age configurable
This commit is contained in:
WithoutPants
2020-04-08 12:51:12 +10:00
committed by GitHub
parent b3e8d1e8dd
commit 15e7756d33
73 changed files with 12297 additions and 49 deletions

View File

@@ -4,6 +4,7 @@ import { Nav, Navbar, Button } from "react-bootstrap";
import { IconName } from "@fortawesome/fontawesome-svg-core";
import { LinkContainer } from "react-router-bootstrap";
import { Link, useLocation } from "react-router-dom";
import { SessionUtils } from "src/utils";
import { Icon } from "src/components/Shared";
@@ -98,6 +99,16 @@ export const MainNavbar: React.FC = () => {
</LinkContainer>
);
function maybeRenderLogout() {
if (SessionUtils.isLoggedIn()) {
return (
<Button className="minimal logout-button" href="/logout">
<Icon icon="sign-out-alt" />
</Button>
);
}
}
return (
<Navbar
collapseOnSelect
@@ -153,6 +164,7 @@ export const MainNavbar: React.FC = () => {
<Icon icon="cog" />
</Button>
</LinkContainer>
{maybeRenderLogout()}
</Nav>
</Navbar>
);