Merge pull request #184 from linkwarden/dev
added the ability to disable registration
This commit is contained in:
commit
ea7f08aba2
|
@ -7,6 +7,7 @@ NEXTAUTH_URL=http://localhost:3000
|
||||||
PAGINATION_TAKE_COUNT=
|
PAGINATION_TAKE_COUNT=
|
||||||
STORAGE_FOLDER=
|
STORAGE_FOLDER=
|
||||||
AUTOSCROLL_TIMEOUT=
|
AUTOSCROLL_TIMEOUT=
|
||||||
|
NEXT_PUBLIC_DISABLE_REGISTRATION=
|
||||||
|
|
||||||
# AWS S3 Settings
|
# AWS S3 Settings
|
||||||
SPACES_KEY=
|
SPACES_KEY=
|
||||||
|
|
|
@ -20,6 +20,10 @@ export default async function Index(
|
||||||
req: NextApiRequest,
|
req: NextApiRequest,
|
||||||
res: NextApiResponse<Data>
|
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 body: User = req.body;
|
||||||
|
|
||||||
const checkHasEmptyFields = emailEnabled
|
const checkHasEmptyFields = emailEnabled
|
||||||
|
|
|
@ -97,15 +97,17 @@ export default function Login() {
|
||||||
className=" w-full text-center"
|
className=" w-full text-center"
|
||||||
loading={submitLoader}
|
loading={submitLoader}
|
||||||
/>
|
/>
|
||||||
<div className="flex items-baseline gap-1 justify-center">
|
{process.env.NEXT_PUBLIC_DISABLE_REGISTRATION === "true" ? undefined : (
|
||||||
<p className="w-fit text-gray-500 dark:text-gray-400">New here?</p>
|
<div className="flex items-baseline gap-1 justify-center">
|
||||||
<Link
|
<p className="w-fit text-gray-500 dark:text-gray-400">New here?</p>
|
||||||
href={"/register"}
|
<Link
|
||||||
className="block text-black dark:text-white font-semibold"
|
href={"/register"}
|
||||||
>
|
className="block text-black dark:text-white font-semibold"
|
||||||
Sign Up
|
>
|
||||||
</Link>
|
Sign Up
|
||||||
</div>
|
</Link>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</CenteredForm>
|
</CenteredForm>
|
||||||
);
|
);
|
||||||
|
|
|
@ -99,134 +99,143 @@ export default function Register() {
|
||||||
: "Create a new account"
|
: "Create a new account"
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<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">
|
{process.env.NEXT_PUBLIC_DISABLE_REGISTRATION === "true" ? (
|
||||||
<p className="text-2xl text-black dark:text-white text-center font-bold">
|
<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">
|
||||||
Enter your details
|
<p>
|
||||||
</p>
|
Registration is disabled for this instance, please contact the admin
|
||||||
<div>
|
in case of any issues.
|
||||||
<p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">
|
|
||||||
Display Name
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<TextInput
|
|
||||||
placeholder="Johnny"
|
|
||||||
value={form.name}
|
|
||||||
className="bg-white"
|
|
||||||
onChange={(e) => setForm({ ...form, name: e.target.value })}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
{emailEnabled ? undefined : (
|
<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
|
||||||
|
</p>
|
||||||
<div>
|
<div>
|
||||||
<p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">
|
<p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">
|
||||||
Username
|
Display Name
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder="john"
|
placeholder="Johnny"
|
||||||
value={form.username}
|
value={form.name}
|
||||||
className="bg-white"
|
className="bg-white"
|
||||||
onChange={(e) => setForm({ ...form, username: e.target.value })}
|
onChange={(e) => setForm({ ...form, name: e.target.value })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
|
|
||||||
{emailEnabled ? (
|
{emailEnabled ? undefined : (
|
||||||
<div>
|
<div>
|
||||||
<p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">
|
<p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">
|
||||||
Email
|
Username
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<TextInput
|
||||||
|
placeholder="john"
|
||||||
|
value={form.username}
|
||||||
|
className="bg-white"
|
||||||
|
onChange={(e) => setForm({ ...form, username: e.target.value })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{emailEnabled ? (
|
||||||
|
<div>
|
||||||
|
<p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">
|
||||||
|
Email
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<TextInput
|
||||||
|
type="email"
|
||||||
|
placeholder="johnny@example.com"
|
||||||
|
value={form.email}
|
||||||
|
className="bg-white"
|
||||||
|
onChange={(e) => setForm({ ...form, email: e.target.value })}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : undefined}
|
||||||
|
|
||||||
|
<div className="w-full">
|
||||||
|
<p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">
|
||||||
|
Password
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<TextInput
|
<TextInput
|
||||||
type="email"
|
type="password"
|
||||||
placeholder="johnny@example.com"
|
placeholder="••••••••••••••"
|
||||||
value={form.email}
|
value={form.password}
|
||||||
className="bg-white"
|
className="bg-white"
|
||||||
onChange={(e) => setForm({ ...form, email: e.target.value })}
|
onChange={(e) => setForm({ ...form, password: e.target.value })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : undefined}
|
|
||||||
|
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">
|
<p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">
|
||||||
Password
|
Confirm Password
|
||||||
</p>
|
|
||||||
|
|
||||||
<TextInput
|
|
||||||
type="password"
|
|
||||||
placeholder="••••••••••••••"
|
|
||||||
value={form.password}
|
|
||||||
className="bg-white"
|
|
||||||
onChange={(e) => setForm({ ...form, password: e.target.value })}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="w-full">
|
|
||||||
<p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">
|
|
||||||
Confirm Password
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<TextInput
|
|
||||||
type="password"
|
|
||||||
placeholder="••••••••••••••"
|
|
||||||
value={form.passwordConfirmation}
|
|
||||||
className="bg-white"
|
|
||||||
onChange={(e) =>
|
|
||||||
setForm({ ...form, passwordConfirmation: e.target.value })
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{process.env.NEXT_PUBLIC_STRIPE_IS_ACTIVE ? (
|
|
||||||
<div>
|
|
||||||
<p className="text-xs text-gray-500 dark:text-gray-400">
|
|
||||||
By signing up, you agree to our{" "}
|
|
||||||
<Link
|
|
||||||
href="https://linkwarden.app/tos"
|
|
||||||
className="font-semibold underline"
|
|
||||||
>
|
|
||||||
Terms of Service
|
|
||||||
</Link>{" "}
|
|
||||||
and{" "}
|
|
||||||
<Link
|
|
||||||
href="https://linkwarden.app/privacy-policy"
|
|
||||||
className="font-semibold underline"
|
|
||||||
>
|
|
||||||
Privacy Policy
|
|
||||||
</Link>
|
|
||||||
.
|
|
||||||
</p>
|
|
||||||
<p className="text-xs text-gray-500 dark:text-gray-400">
|
|
||||||
Need help?{" "}
|
|
||||||
<Link
|
|
||||||
href="mailto:support@linkwarden.app"
|
|
||||||
className="font-semibold underline"
|
|
||||||
>
|
|
||||||
Get in touch
|
|
||||||
</Link>
|
|
||||||
.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<TextInput
|
||||||
|
type="password"
|
||||||
|
placeholder="••••••••••••••"
|
||||||
|
value={form.passwordConfirmation}
|
||||||
|
className="bg-white"
|
||||||
|
onChange={(e) =>
|
||||||
|
setForm({ ...form, passwordConfirmation: e.target.value })
|
||||||
|
}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : undefined}
|
|
||||||
|
|
||||||
<SubmitButton
|
{process.env.NEXT_PUBLIC_STRIPE_IS_ACTIVE ? (
|
||||||
onClick={registerUser}
|
<div>
|
||||||
label="Sign Up"
|
<p className="text-xs text-gray-500 dark:text-gray-400">
|
||||||
className="mt-2 w-full text-center"
|
By signing up, you agree to our{" "}
|
||||||
loading={submitLoader}
|
<Link
|
||||||
/>
|
href="https://linkwarden.app/tos"
|
||||||
<div className="flex items-baseline gap-1 justify-center">
|
className="font-semibold underline"
|
||||||
<p className="w-fit text-gray-500 dark:text-gray-400">
|
>
|
||||||
Already have an account?
|
Terms of Service
|
||||||
</p>
|
</Link>{" "}
|
||||||
<Link
|
and{" "}
|
||||||
href={"/login"}
|
<Link
|
||||||
className="block text-black dark:text-white font-bold"
|
href="https://linkwarden.app/privacy-policy"
|
||||||
>
|
className="font-semibold underline"
|
||||||
Login
|
>
|
||||||
</Link>
|
Privacy Policy
|
||||||
|
</Link>
|
||||||
|
.
|
||||||
|
</p>
|
||||||
|
<p className="text-xs text-gray-500 dark:text-gray-400">
|
||||||
|
Need help?{" "}
|
||||||
|
<Link
|
||||||
|
href="mailto:support@linkwarden.app"
|
||||||
|
className="font-semibold underline"
|
||||||
|
>
|
||||||
|
Get in touch
|
||||||
|
</Link>
|
||||||
|
.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
) : undefined}
|
||||||
|
|
||||||
|
<SubmitButton
|
||||||
|
onClick={registerUser}
|
||||||
|
label="Sign Up"
|
||||||
|
className="mt-2 w-full text-center"
|
||||||
|
loading={submitLoader}
|
||||||
|
/>
|
||||||
|
<div className="flex items-baseline gap-1 justify-center">
|
||||||
|
<p className="w-fit text-gray-500 dark:text-gray-400">
|
||||||
|
Already have an account?
|
||||||
|
</p>
|
||||||
|
<Link
|
||||||
|
href={"/login"}
|
||||||
|
className="block text-black dark:text-white font-bold"
|
||||||
|
>
|
||||||
|
Login
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
)}
|
||||||
</CenteredForm>
|
</CenteredForm>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ declare global {
|
||||||
NEXTAUTH_SECRET: string;
|
NEXTAUTH_SECRET: string;
|
||||||
DATABASE_URL: string;
|
DATABASE_URL: string;
|
||||||
NEXTAUTH_URL: string;
|
NEXTAUTH_URL: string;
|
||||||
|
NEXT_PUBLIC_DISABLE_REGISTRATION?: string;
|
||||||
PAGINATION_TAKE_COUNT?: string;
|
PAGINATION_TAKE_COUNT?: string;
|
||||||
STORAGE_FOLDER?: string;
|
STORAGE_FOLDER?: string;
|
||||||
AUTOSCROLL_TIMEOUT?: string;
|
AUTOSCROLL_TIMEOUT?: string;
|
||||||
|
|
Ŝarĝante…
Reference in New Issue