chore: added varaible enable OAuth

This commit is contained in:
Henit Chobisa 2023-09-06 06:33:01 +00:00
parent 260b752ae4
commit 4aac7ffac1
3 changed files with 12 additions and 6 deletions

View File

@ -43,7 +43,7 @@ const HomePage: NextPage = observer(() => {
const { setTheme } = useTheme(); const { setTheme } = useTheme();
const { const {
publicRuntimeConfig: { PROJECT_API }, publicRuntimeConfig: { NEXT_PUBLIC_ENABLE_OAUTH },
} = getConfig() } = getConfig()
const { isLoading, mutateUser } = useUserAuth("sign-in"); const { isLoading, mutateUser } = useUserAuth("sign-in");
@ -178,10 +178,10 @@ const HomePage: NextPage = observer(() => {
</> </>
<div className="grid place-items-center h-full overflow-y-auto py-5 px-7"> <div className="grid place-items-center h-full overflow-y-auto py-5 px-7">
<div> <div>
{parseInt(process.env.NEXT_PUBLIC_ENABLE_OAUTH || "0") ? ( {parseInt(NEXT_PUBLIC_ENABLE_OAUTH || "0") ? (
<> <>
<h1 className="text-center text-2xl sm:text-2.5xl font-semibold text-custom-text-100"> <h1 className="text-center text-2xl sm:text-2.5xl font-semibold text-custom-text-100">
{ `Sign in to ${PROJECT_API} Plane` } { `Sign in to Plane` }
</h1> </h1>
<div className="flex flex-col divide-y divide-custom-border-200"> <div className="flex flex-col divide-y divide-custom-border-200">
<div className="pb-7"> <div className="pb-7">
@ -197,7 +197,7 @@ const HomePage: NextPage = observer(() => {
<EmailPasswordForm onSubmit={handlePasswordSignIn} /> <EmailPasswordForm onSubmit={handlePasswordSignIn} />
)} )}
{parseInt(process.env.NEXT_PUBLIC_ENABLE_OAUTH || "0") ? ( {parseInt(NEXT_PUBLIC_ENABLE_OAUTH || "0") ? (
<p className="pt-16 text-custom-text-200 text-sm text-center"> <p className="pt-16 text-custom-text-200 text-sm text-center">
By signing up, you agree to the{" "} By signing up, you agree to the{" "}
<a <a

View File

@ -19,6 +19,7 @@ import { Input, PrimaryButton, Spinner } from "components/ui";
import BluePlaneLogoWithoutText from "public/plane-logos/blue-without-text.png"; import BluePlaneLogoWithoutText from "public/plane-logos/blue-without-text.png";
// types // types
import type { NextPage } from "next"; import type { NextPage } from "next";
import getConfig from "next/config";
type FormData = { type FormData = {
password: string; password: string;
@ -28,6 +29,8 @@ type FormData = {
const ResetPasswordPage: NextPage = () => { const ResetPasswordPage: NextPage = () => {
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
const { publicRuntimeConfig: { NEXT_PUBLIC_ENABLE_OAUTH } } = getConfig();
const router = useRouter(); const router = useRouter();
const { uidb64, token } = router.query; const { uidb64, token } = router.query;
@ -85,7 +88,7 @@ const ResetPasswordPage: NextPage = () => {
}, [setTheme]); }, [setTheme]);
useEffect(() => { useEffect(() => {
if (parseInt(process.env.NEXT_PUBLIC_ENABLE_OAUTH || "0")) router.push("/"); if (parseInt(NEXT_PUBLIC_ENABLE_OAUTH || "0")) router.push("/");
else setIsLoading(false); else setIsLoading(false);
}, [router]); }, [router]);

View File

@ -18,6 +18,7 @@ import { EmailPasswordForm } from "components/account";
import { Spinner } from "components/ui"; import { Spinner } from "components/ui";
// images // images
import BluePlaneLogoWithoutText from "public/plane-logos/blue-without-text.png"; import BluePlaneLogoWithoutText from "public/plane-logos/blue-without-text.png";
import getConfig from "next/config";
// types // types
import type { NextPage } from "next"; import type { NextPage } from "next";
type EmailPasswordFormValues = { type EmailPasswordFormValues = {
@ -29,6 +30,8 @@ type EmailPasswordFormValues = {
const SignUp: NextPage = () => { const SignUp: NextPage = () => {
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
const { publicRuntimeConfig: { NEXT_PUBLIC_ENABLE_OAUTH } } = getConfig();
const router = useRouter(); const router = useRouter();
const { setToastAlert } = useToast(); const { setToastAlert } = useToast();
@ -71,7 +74,7 @@ const SignUp: NextPage = () => {
}, [setTheme]); }, [setTheme]);
useEffect(() => { useEffect(() => {
if (parseInt(process.env.NEXT_PUBLIC_ENABLE_OAUTH || "0")) router.push("/"); if (parseInt(NEXT_PUBLIC_ENABLE_OAUTH || "0")) router.push("/");
else setIsLoading(false); else setIsLoading(false);
}, [router]); }, [router]);