diff --git a/.env.example b/.env.example index e1d18c586..b5ffd2af1 100644 --- a/.env.example +++ b/.env.example @@ -18,4 +18,8 @@ NEXTAUTH_URL='http://localhost:3000' # You can also configure you own SMTP server using Nodemailer in sendMailts. (currently not possible via config) SENDGRID_API_KEY='' # Sender for signing requests and completion mails. -MAIL_FROM='' \ No newline at end of file +MAIL_FROM='' + +#FEATURE FLAGS +# Allow users to register via the /signup page. Otherwise they will be redirect to the home page. +ALLOW_SIGNUP=false \ No newline at end of file diff --git a/apps/web/components/login.tsx b/apps/web/components/login.tsx index 8f4e612c1..c8deb1eee 100644 --- a/apps/web/components/login.tsx +++ b/apps/web/components/login.tsx @@ -17,12 +17,11 @@ interface LoginValues { csrfToken: string; } -export default function Login() { +export default function Login(props: any) { const router = useRouter(); const methods = useForm(); const { register, formState } = methods; const [errorMessage, setErrorMessage] = useState(null); - let callbackUrl = typeof router.query?.callbackUrl === "string" ? router.query.callbackUrl @@ -117,7 +116,6 @@ export default function Login() { /> -
@@ -125,7 +123,6 @@ export default function Login() {
-
-

- Are you new here?{" "} - - Create a new Account - -

+ {props.allowSignup ? ( +

+ Are you new here?{" "} + + Create a new Account + +

+ ) : null} diff --git a/apps/web/pages/login.tsx b/apps/web/pages/login.tsx index d9fffa562..ca384369a 100644 --- a/apps/web/pages/login.tsx +++ b/apps/web/pages/login.tsx @@ -1,13 +1,23 @@ import Head from "next/head"; import Login from "../components/login"; -export default function LoginPage() { +export default function LoginPage(props: any) { return ( <> Login | Documenso - + ); } + +export async function getServerSideProps(context: any) { + const ALLOW_SIGNUP = process.env.ALLOW_SIGNUP === "true"; + + return { + props: { + ALLOW_SIGNUP: ALLOW_SIGNUP, + }, + }; +} diff --git a/apps/web/pages/signup.tsx b/apps/web/pages/signup.tsx index c984350de..f2e6858e1 100644 --- a/apps/web/pages/signup.tsx +++ b/apps/web/pages/signup.tsx @@ -15,6 +15,15 @@ export default function SignupPage(props: { source: string }) { export async function getServerSideProps(context: any) { const signupSource: string = context.query["source"]; + + if (process.env.ALLOW_SIGNUP === "false") + return { + redirect: { + destination: "/login", + permanent: false, + }, + }; + return { props: { source: signupSource ? signupSource : "",