mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix: made project list authenticated (#428)
This commit is contained in:
parent
0ba81a10f1
commit
0117ccfca2
@ -1,6 +1,8 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { mutate } from "swr";
|
import { mutate } from "swr";
|
||||||
|
// lib
|
||||||
|
import { requiredAuth } from "lib/auth";
|
||||||
// services
|
// services
|
||||||
import projectService from "services/project.service";
|
import projectService from "services/project.service";
|
||||||
// hooks
|
// hooks
|
||||||
@ -17,7 +19,7 @@ import { Breadcrumbs, BreadcrumbItem } from "components/breadcrumbs";
|
|||||||
// icons
|
// icons
|
||||||
import { ClipboardDocumentListIcon, PlusIcon } from "@heroicons/react/24/outline";
|
import { ClipboardDocumentListIcon, PlusIcon } from "@heroicons/react/24/outline";
|
||||||
// types
|
// types
|
||||||
import type { NextPage } from "next";
|
import type { GetServerSidePropsContext, NextPage } from "next";
|
||||||
// fetch-keys
|
// fetch-keys
|
||||||
import { PROJECT_MEMBERS } from "constants/fetch-keys";
|
import { PROJECT_MEMBERS } from "constants/fetch-keys";
|
||||||
|
|
||||||
@ -127,4 +129,25 @@ const ProjectsPage: NextPage = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
|
||||||
|
const user = await requiredAuth(ctx.req?.headers.cookie);
|
||||||
|
|
||||||
|
const redirectAfterSignIn = ctx.resolvedUrl;
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
return {
|
||||||
|
redirect: {
|
||||||
|
destination: `/signin?next=${redirectAfterSignIn}`,
|
||||||
|
permanent: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
user,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export default ProjectsPage;
|
export default ProjectsPage;
|
||||||
|
Loading…
Reference in New Issue
Block a user