⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
added the ability to disable registration
daniel31x13fdcae013c679
diff --git a/.env.sample b/.env.sampleindex a2cc611a..b6eebf3c 100644--- a/.env.sample+++ b/.env.sample@@ -7,6 +7,7 @@ NEXTAUTH_URL=http://localhost:3000PAGINATION_TAKE_COUNT=STORAGE_FOLDER=AUTOSCROLL_TIMEOUT=+NEXT_PUBLIC_DISABLE_REGISTRATION=# AWS S3 SettingsSPACES_KEY=diff --git a/pages/api/auth/register.ts b/pages/api/auth/register.tsindex c7e51368..72477650 100644--- a/pages/api/auth/register.ts+++ b/pages/api/auth/register.ts@@ -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 = emailEnableddiff --git a/pages/login.tsx b/pages/login.tsxindex 1655218a..f06d3b4b 100644--- a/pages/login.tsx+++ b/pages/login.tsx@@ -97,15 +97,17 @@ export default function Login() {className=" 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">New here?</p>- <Link- href={"/register"}- className="block text-black dark:text-white font-semibold"- >- Sign Up- </Link>- </div>+ {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+ href={"/register"}+ className="block text-black dark:text-white font-semibold"+ >+ Sign Up+ </Link>+ </div>+ )}</div></CenteredForm>);diff --git a/pages/register.tsx b/pages/register.tsxindex c719cb53..75ba5251 100644--- a/pages/register.tsx+++ b/pages/register.tsx@@ -99,134 +99,143 @@ export default function Register() {: "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">- <p className="text-2xl text-black dark:text-white text-center font-bold">- Enter your details- </p>- <div>- <p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">- Display Name+ {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>-- <TextInput- placeholder="Johnny"- value={form.name}- className="bg-white"- onChange={(e) => setForm({ ...form, name: e.target.value })}- /></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><p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">- Username+ Display Name</p><TextInput- placeholder="john"- value={form.username}+ placeholder="Johnny"+ value={form.name}className="bg-white"- onChange={(e) => setForm({ ...form, username: e.target.value })}+ onChange={(e) => setForm({ ...form, name: e.target.value })}/></div>- )}- {emailEnabled ? (- <div>- <p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">+ {emailEnabled ? undefined : (+ <div>+ <p className="text-sm text-black dark:text-white w-fit font-semibold mb-1">+ 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">+ </p>++ <TextInput+ type="email"+ placeholder="[email protected]"+ 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><TextInput- type="email"- placeholder="[email protected]"- value={form.email}+ type="password"+ placeholder="••••••••••••••"+ value={form.password}className="bg-white"- onChange={(e) => setForm({ ...form, email: e.target.value })}+ onChange={(e) => setForm({ ...form, password: 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>-- <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>- <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>- <TextInput- type="password"- placeholder="••••••••••••••"- value={form.passwordConfirmation}- className="bg-white"- onChange={(e) =>- setForm({ ...form, passwordConfirmation: e.target.value })- }+ {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:[email protected]"+ 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>-- {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:[email protected]"- className="font-semibold underline"- >- Get in touch- </Link>- .+ <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>- ) : 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>+ )}</CenteredForm>);}diff --git a/types/enviornment.d.ts b/types/enviornment.d.tsindex 946b2a82..8e4c9dbf 100644--- a/types/enviornment.d.ts+++ b/types/enviornment.d.ts@@ -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;