mirror of
https://github.com/documenso/documenso.git
synced 2025-11-15 17:21:41 +10:00
feature flag for signup
This commit is contained in:
@ -19,3 +19,7 @@ NEXTAUTH_URL='http://localhost:3000'
|
|||||||
SENDGRID_API_KEY=''
|
SENDGRID_API_KEY=''
|
||||||
# Sender for signing requests and completion mails.
|
# Sender for signing requests and completion mails.
|
||||||
MAIL_FROM=''
|
MAIL_FROM=''
|
||||||
|
|
||||||
|
#FEATURE FLAGS
|
||||||
|
# Allow users to register via the /signup page. Otherwise they will be redirect to the home page.
|
||||||
|
ALLOW_SIGNUP=false
|
||||||
@ -17,12 +17,11 @@ interface LoginValues {
|
|||||||
csrfToken: string;
|
csrfToken: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Login() {
|
export default function Login(props: any) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const methods = useForm<LoginValues>();
|
const methods = useForm<LoginValues>();
|
||||||
const { register, formState } = methods;
|
const { register, formState } = methods;
|
||||||
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
||||||
|
|
||||||
let callbackUrl =
|
let callbackUrl =
|
||||||
typeof router.query?.callbackUrl === "string"
|
typeof router.query?.callbackUrl === "string"
|
||||||
? router.query.callbackUrl
|
? router.query.callbackUrl
|
||||||
@ -117,7 +116,6 @@ export default function Login() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div className="text-sm">
|
<div className="text-sm">
|
||||||
<a href="#" className="font-medium text-neon hover:text-neon">
|
<a href="#" className="font-medium text-neon hover:text-neon">
|
||||||
@ -125,7 +123,6 @@ export default function Login() {
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
@ -152,6 +149,7 @@ export default function Login() {
|
|||||||
<div className="relative flex justify-center"></div>
|
<div className="relative flex justify-center"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{props.allowSignup ? (
|
||||||
<p className="mt-2 text-center text-sm text-gray-600">
|
<p className="mt-2 text-center text-sm text-gray-600">
|
||||||
Are you new here?{" "}
|
Are you new here?{" "}
|
||||||
<Link
|
<Link
|
||||||
@ -161,6 +159,7 @@ export default function Login() {
|
|||||||
Create a new Account
|
Create a new Account
|
||||||
</Link>
|
</Link>
|
||||||
</p>
|
</p>
|
||||||
|
) : null}
|
||||||
</form>
|
</form>
|
||||||
</FormProvider>
|
</FormProvider>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,13 +1,23 @@
|
|||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import Login from "../components/login";
|
import Login from "../components/login";
|
||||||
|
|
||||||
export default function LoginPage() {
|
export default function LoginPage(props: any) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
<title>Login | Documenso</title>
|
<title>Login | Documenso</title>
|
||||||
</Head>
|
</Head>
|
||||||
<Login></Login>
|
<Login allowSignup={props.ALLOW_SIGNUP}></Login>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getServerSideProps(context: any) {
|
||||||
|
const ALLOW_SIGNUP = process.env.ALLOW_SIGNUP === "true";
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
ALLOW_SIGNUP: ALLOW_SIGNUP,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@ -15,6 +15,15 @@ export default function SignupPage(props: { source: string }) {
|
|||||||
|
|
||||||
export async function getServerSideProps(context: any) {
|
export async function getServerSideProps(context: any) {
|
||||||
const signupSource: string = context.query["source"];
|
const signupSource: string = context.query["source"];
|
||||||
|
|
||||||
|
if (process.env.ALLOW_SIGNUP === "false")
|
||||||
|
return {
|
||||||
|
redirect: {
|
||||||
|
destination: "/login",
|
||||||
|
permanent: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
source: signupSource ? signupSource : "",
|
source: signupSource ? signupSource : "",
|
||||||
|
|||||||
Reference in New Issue
Block a user