From a287fec381094ab8254937b02a40203559f39d70 Mon Sep 17 00:00:00 2001 From: Artem VV Date: Fri, 19 May 2023 21:15:26 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=81=D1=85=D0=B5=D0=BC=D1=83,=20=D0=B4=D0=BE=D0=B1?= =?UTF-8?q?=D0=B0=D0=B2=D0=B8=D0=BB=20=D0=B8=D0=BD=D1=84=D1=83=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8F=20=D0=B2=20=D0=BD=D0=B0=D0=B2=D0=B1=D0=B0?= =?UTF-8?q?=D1=80=20=D0=B5=D1=81=D0=BB=D0=B8=20=D0=BF=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C=20=D0=B0=D0=B4?= =?UTF-8?q?=D0=BC=D0=B8=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prisma/schema.prisma | 4 ++-- src/components/Navbar.astro | 26 ++++++++++++++++++++++++++ src/pages/articleEditor.astro | 2 +- src/pages/index.astro | 10 +++------- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index dbf006e..9240335 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -55,8 +55,8 @@ model timetable { model users { id Int @id(map: "pk_users") @default(autoincrement()) login String @unique @db.VarChar(25) - pass String? @db.VarChar(100) - is_admin Boolean? @default(false) + pass String @db.VarChar(100) + is_admin Boolean @default(false) timetable timetable[] user_session user_session[] } diff --git a/src/components/Navbar.astro b/src/components/Navbar.astro index 5bb2140..51b8acb 100644 --- a/src/components/Navbar.astro +++ b/src/components/Navbar.astro @@ -1,4 +1,10 @@ --- +export interface Props { + is_user_admin: boolean; +} + +const { is_user_admin } = Astro.props; + const items = [ { href: "/", @@ -8,6 +14,14 @@ const items = [ href: "/timetable", title: "Расписание", }, +]; +if (is_user_admin) { + items.push({ + href: "/users", + title: "Пользователи", + }); +} +const itemsRight = [ { href: "/logout", title: "Выйти", @@ -28,5 +42,17 @@ const items = [ )) } +
+ diff --git a/src/pages/articleEditor.astro b/src/pages/articleEditor.astro index d9d1767..8ff8112 100644 --- a/src/pages/articleEditor.astro +++ b/src/pages/articleEditor.astro @@ -20,7 +20,7 @@ if (articleId) {
- +
diff --git a/src/pages/index.astro b/src/pages/index.astro index fb75604..1c4e82a 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -17,17 +17,13 @@ if (Astro.cookies.has("session")) { return Astro.redirect("/login"); } -const { news, alerts } = await getNewsAndAlerts(); - -const items: NavbarItemType[] = [ - { text: "Новости", href: "/" }, - { text: "Расписание", href: "/timetable" }, -]; +const sessId = Astro.cookies.get("session").value!; +const user = (await getSessionUser(sessId))!; ---
- +