added the ability to disable registration

This commit is contained in:
daniel31x13
2023-09-28 19:07:25 +03:30
parent 7585d52750
commit fdcae013c6
5 changed files with 132 additions and 115 deletions
+1
View File
@@ -7,6 +7,7 @@ NEXTAUTH_URL=http://localhost:3000
PAGINATION_TAKE_COUNT=
STORAGE_FOLDER=
AUTOSCROLL_TIMEOUT=
NEXT_PUBLIC_DISABLE_REGISTRATION=
# AWS S3 Settings
SPACES_KEY=
+4
View File
@@ -20,6 +20,10 @@ export default async function Index(
req: NextApiRequest,
res: NextApiResponse<Data>
) {
if (process.env.NEXT_PUBLIC_DISABLE_REGISTRATION === "true") {
return res.status(400).json({ response: "Registration is disabled." });
}
const body: User = req.body;
const checkHasEmptyFields = emailEnabled
+2
View File
@@ -97,6 +97,7 @@ export default function Login() {
className=" w-full text-center"
loading={submitLoader}
/>
{process.env.NEXT_PUBLIC_DISABLE_REGISTRATION === "true" ? undefined : (
<div className="flex items-baseline gap-1 justify-center">
<p className="w-fit text-gray-500 dark:text-gray-400">New here?</p>
<Link
@@ -106,6 +107,7 @@ export default function Login() {
Sign Up
</Link>
</div>
)}
</div>
</CenteredForm>
);
+9
View File
@@ -99,6 +99,14 @@ export default function Register() {
: "Create a new account"
}
>
{process.env.NEXT_PUBLIC_DISABLE_REGISTRATION === "true" ? (
<div className="p-4 flex flex-col gap-3 justify-between sm:w-[30rem] w-80 bg-slate-50 dark:bg-neutral-800 rounded-2xl shadow-md border border-sky-100 dark:border-neutral-700">
<p>
Registration is disabled for this instance, please contact the admin
in case of any issues.
</p>
</div>
) : (
<div className="p-4 flex flex-col gap-3 justify-between sm:w-[30rem] w-80 bg-slate-50 dark:bg-neutral-800 rounded-2xl shadow-md border border-sky-100 dark:border-neutral-700">
<p className="text-2xl text-black dark:text-white text-center font-bold">
Enter your details
@@ -227,6 +235,7 @@ export default function Register() {
</Link>
</div>
</div>
)}
</CenteredForm>
);
}
+1
View File
@@ -4,6 +4,7 @@ declare global {
NEXTAUTH_SECRET: string;
DATABASE_URL: string;
NEXTAUTH_URL: string;
NEXT_PUBLIC_DISABLE_REGISTRATION?: string;
PAGINATION_TAKE_COUNT?: string;
STORAGE_FOLDER?: string;
AUTOSCROLL_TIMEOUT?: string;