mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: handled auth wrapper
This commit is contained in:
parent
b87a43c8fe
commit
4054d52940
@ -1,4 +1,5 @@
|
|||||||
import { FC, ReactNode } from "react";
|
import { FC, ReactNode } from "react";
|
||||||
|
import { observer } from "mobx-react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
import { Spinner } from "@plane/ui";
|
import { Spinner } from "@plane/ui";
|
||||||
@ -19,7 +20,7 @@ const isValidURL = (url: string): boolean => {
|
|||||||
return !disallowedSchemes.test(url);
|
return !disallowedSchemes.test(url);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AuthenticationWrapper: FC<TAuthenticationWrapper> = (props) => {
|
export const AuthenticationWrapper: FC<TAuthenticationWrapper> = observer((props) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { next_path } = router.query;
|
const { next_path } = router.query;
|
||||||
// props
|
// props
|
||||||
@ -34,7 +35,7 @@ export const AuthenticationWrapper: FC<TAuthenticationWrapper> = (props) => {
|
|||||||
} = useUser();
|
} = useUser();
|
||||||
const { loader: workspaceLoader, workspaces, fetchWorkspaces } = useWorkspace();
|
const { loader: workspaceLoader, workspaces, fetchWorkspaces } = useWorkspace();
|
||||||
|
|
||||||
useSWR("USER_INFORMATION", () => fetchCurrentUser(), {
|
useSWR("USER_INFORMATION", async () => fetchCurrentUser(), {
|
||||||
revalidateOnFocus: false,
|
revalidateOnFocus: false,
|
||||||
shouldRetryOnError: false,
|
shouldRetryOnError: false,
|
||||||
});
|
});
|
||||||
@ -42,7 +43,7 @@ export const AuthenticationWrapper: FC<TAuthenticationWrapper> = (props) => {
|
|||||||
useSWR(
|
useSWR(
|
||||||
currentUser && currentUser?.id ? "USER_PROFILE_SETTINGS_INFORMATION" : null,
|
currentUser && currentUser?.id ? "USER_PROFILE_SETTINGS_INFORMATION" : null,
|
||||||
async () => {
|
async () => {
|
||||||
if (currentUser) {
|
if (currentUser && currentUser?.id) {
|
||||||
fetchCurrentUserSettings();
|
fetchCurrentUserSettings();
|
||||||
fetchUserProfile();
|
fetchUserProfile();
|
||||||
fetchWorkspaces();
|
fetchWorkspaces();
|
||||||
@ -126,4 +127,4 @@ export const AuthenticationWrapper: FC<TAuthenticationWrapper> = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
};
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user