aboutsummaryrefslogtreecommitdiffstats
path: root/middleware
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.com>2025-01-17 13:42:21 +0000
committerLeonardo Bishop <me@leonardobishop.com>2025-01-17 13:42:21 +0000
commit70ebc77f843207a1d4b46c8d960dafbff37e7e2e (patch)
tree2d03f7a66b877bb6ffa2f92c0504ac90f26db55f /middleware
Initial commit
Diffstat (limited to 'middleware')
-rw-r--r--middleware/logged-in.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/middleware/logged-in.ts b/middleware/logged-in.ts
new file mode 100644
index 0000000..1ddd3ce
--- /dev/null
+++ b/middleware/logged-in.ts
@@ -0,0 +1,21 @@
+export default defineNuxtRouteMiddleware((to, from) => {
+ if ("" === getCookie("fosdem_planner_session")) {
+ return navigateTo("/login");
+ }
+});
+
+function getCookie(cname: string) {
+ let name = cname + "=";
+ let decodedCookie = decodeURIComponent(document.cookie);
+ let ca = decodedCookie.split(";");
+ for (let i = 0; i < ca.length; i++) {
+ let c = ca[i];
+ while (c.charAt(0) == " ") {
+ c = c.substring(1);
+ }
+ if (c.indexOf(name) == 0) {
+ return c.substring(name.length, c.length);
+ }
+ }
+ return "";
+}