Fixed creation of users + better frontend handling of permissions
This commit is contained in:
16
frontend/app/(auth)/dashboard/blogs/new/_new.tsx
Normal file
16
frontend/app/(auth)/dashboard/blogs/new/_new.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
"use client";
|
||||
|
||||
import { Loader2 } from "lucide-react";
|
||||
import dynamic from "next/dynamic";
|
||||
|
||||
const BlogEditor = dynamic(
|
||||
() => import("@/components/article/edit").then((mod) => mod.default),
|
||||
{
|
||||
ssr: false,
|
||||
loading: () => <Loader2 className="animate-spin" />,
|
||||
},
|
||||
);
|
||||
|
||||
export default function NewBlog() {
|
||||
return <BlogEditor />;
|
||||
}
|
||||
@@ -1,16 +1,21 @@
|
||||
"use client";
|
||||
"use server";
|
||||
import getMe from "@/lib/getMe";
|
||||
import hasPermissions from "@/lib/hasPermissions";
|
||||
import { redirect } from "next/navigation";
|
||||
import NewBlog from "./_new";
|
||||
|
||||
import { Loader2 } from "lucide-react";
|
||||
import dynamic from "next/dynamic";
|
||||
export default async function Page() {
|
||||
const me = await getMe();
|
||||
if (
|
||||
!me ||
|
||||
me.status === "Error" ||
|
||||
!me.data ||
|
||||
!hasPermissions(me.data.roles, {
|
||||
blogs: ["insert"],
|
||||
} as const).all
|
||||
) {
|
||||
redirect("/dashboard");
|
||||
}
|
||||
|
||||
const BlogEditor = dynamic(
|
||||
() => import("@/components/article/edit").then((mod) => mod.default),
|
||||
{
|
||||
ssr: false,
|
||||
loading: () => <Loader2 className="animate-spin" />,
|
||||
},
|
||||
);
|
||||
|
||||
export default function Page() {
|
||||
return <BlogEditor />;
|
||||
return <NewBlog />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user