Skip to content
Snippets Groups Projects
Commit 4e252dfe authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

logout button

parent b791487e
No related branches found
No related tags found
No related merge requests found
...@@ -115,13 +115,19 @@ button { ...@@ -115,13 +115,19 @@ button {
text-decoration: none; text-decoration: none;
background-color: @color-secondary; background-color: @color-secondary;
width: max-content; width: max-content;
&:hover { &:hover {
color: inherit; color: inherit;
background-color: fade(@color-secondary, 70%); background-color: fade(@color-secondary, 70%);
border-color: @color-main; border-color: @color-main;
color: fade(white, 90%); color: fade(white, 90%);
} }
&.negative {
background-color: @color-negative;
&:hover {
background-color: fade(@color-negative, 70%);
color: white;
}
}
} }
nav#primary-nav { nav#primary-nav {
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
@color-secondary: #3a3af9; @color-secondary: #3a3af9;
@color-main-hover: lighten(@color-main, 5%); @color-main-hover: lighten(@color-main, 5%);
@color-main-font-color: white; @color-main-font-color: white;
@color-negative: rgba(255, 0, 0, 0.432);
@font-color-on-white: #515151; @font-color-on-white: #515151;
......
...@@ -16,6 +16,13 @@ router.get("/create", function (req, res, next) { ...@@ -16,6 +16,13 @@ router.get("/create", function (req, res, next) {
}); });
}); });
router.get("/remove", (req, res) => {
if (req.cookies.key) {
res.clearCookie("key");
}
res.redirect("/");
})
router.get("/enter", function (req, res, next) { router.get("/enter", function (req, res, next) {
if (req.cookies.key) { if (req.cookies.key) {
res.redirect("/key/" + encodeURIComponent(req.cookies.key)); res.redirect("/key/" + encodeURIComponent(req.cookies.key));
...@@ -106,6 +113,7 @@ router.use("/:key", param("key").isUUID(4), async (req, res, next) => { ...@@ -106,6 +113,7 @@ router.use("/:key", param("key").isUUID(4), async (req, res, next) => {
settings_url: metager_url, settings_url: metager_url,
qr: qr_data_uri, qr: qr_data_uri,
}, },
cookies: req.cookies,
page: "fill", page: "fill",
links: { links: {
fill_url: `/key/${req.params.key}`, fill_url: `/key/${req.params.key}`,
...@@ -116,7 +124,9 @@ router.use("/:key", param("key").isUUID(4), async (req, res, next) => { ...@@ -116,7 +124,9 @@ router.use("/:key", param("key").isUUID(4), async (req, res, next) => {
}); });
if (!req.data.admin && (!req.cookies.key || req.cookies.key !== req.data.key.key)) { if (!req.data.admin && (!req.cookies.key || req.cookies.key !== req.data.key.key)) {
res.cookie("key", req.data.key.key); res.cookie("key", req.data.key.key, {
sameSite: "lax"
});
} }
next("route"); next("route");
......
...@@ -42,7 +42,11 @@ ...@@ -42,7 +42,11 @@
<li><a href="#">Hilfe</a></li> <li><a href="#">Hilfe</a></li>
<li class="whitespace"></li> <li class="whitespace"></li>
<li><a href="/key/enter">Schlüssel verwalten</a></li> <li><a href="/key/enter">Schlüssel verwalten</a></li>
<li><a href="/key/create" class="button">Starten</a></li> <%_ if((typeof cookies !== "undefined" && typeof cookies.key !== "undefined") || typeof key !== "undefined") { _%>
<li><a href="/key/remove" class="button negative" id="key-remove">Schlüssel entfernen</a></li>
<%_ } else { _%>
<li><a href="/key/create" class="button">Starten</a></li>
<%_ } _%>
</ul> </ul>
</nav> </nav>
<main> <main>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment