31 lines
846 B
Text
31 lines
846 B
Text
---
|
|
import Layout from "../layouts/Layout.astro";
|
|
import type { NavbarItemType } from "astro-bootstrap";
|
|
|
|
import { getUserSession, getNewsAndAlerts, getSessionUser } from "../db";
|
|
import NewsBlock from "../components/NewsBlock.astro";
|
|
import Navbar from "../components/Navbar.astro";
|
|
|
|
if (Astro.cookies.has("session")) {
|
|
const sessId = Astro.cookies.get("session").value!;
|
|
const dbSess = await getUserSession(sessId);
|
|
if (dbSess === null) {
|
|
Astro.cookies.delete("session");
|
|
return Astro.redirect("/login");
|
|
}
|
|
} else {
|
|
return Astro.redirect("/login");
|
|
}
|
|
|
|
const sessId = Astro.cookies.get("session").value!;
|
|
const user = (await getSessionUser(sessId))!;
|
|
---
|
|
|
|
<Layout title="Новости">
|
|
<main>
|
|
<Navbar is_user_admin={user.is_admin} />
|
|
<NewsBlock />
|
|
</main>
|
|
</Layout>
|
|
|
|
<style></style>
|