feat: add authentication
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user