FPSMS-frontend
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

23 lines
578 B

  1. import { Metadata } from "next";
  2. import { getServerSession } from "next-auth";
  3. import { redirect } from "next/navigation";
  4. import { authOptions } from "@/config/authConfig";
  5. import { AUTH } from "@/authorities";
  6. export const metadata: Metadata = {
  7. title: "M18 Sync",
  8. };
  9. export default async function M18SynLayout({
  10. children,
  11. }: {
  12. children: React.ReactNode;
  13. }) {
  14. const session = await getServerSession(authOptions);
  15. const abilities = session?.user?.abilities ?? [];
  16. if (!abilities.includes(AUTH.ADMIN)) {
  17. redirect("/dashboard");
  18. }
  19. return <>{children}</>;
  20. }