feat: add authentication

This commit is contained in:
2023-08-04 22:35:25 +02:00
parent f9638c35fc
commit 469db6525d
33 changed files with 492 additions and 100 deletions

View File

@@ -2,6 +2,7 @@ import { Menu } from "@islands/KMenu/types.ts";
import { addMovieInfos } from "@islands/KMenu/commands/add_movie_infos.ts";
import { createNewMovie } from "@islands/KMenu/commands/create_movie.ts";
import { createNewArticle } from "@islands/KMenu/commands/create_article.ts";
import { getCookie } from "@lib/string.ts";
export const menus: Record<string, Menu> = {
main: {
@@ -18,6 +19,30 @@ export const menus: Record<string, Menu> = {
state.activeState.value = "normal";
state.visible.value = false;
},
visible: () => {
if (!getCookie("session_cookie")) return false;
return true;
},
},
{
title: "Login",
icon: "IconLogin",
cb: () => {
window.location.pathname = "/api/auth/login";
},
visible: () => {
return !getCookie("session_cookie");
},
},
{
title: "Logout",
icon: "IconLogout",
cb: () => {
window.location.pathname = "/api/auth/logout";
},
visible: () => {
return !!getCookie("session_cookie");
},
},
createNewArticle,
createNewMovie,