Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

feat: add registration control feature (#134)

Andrej5b866368581f
diff --git a/README.md b/README.md
index 95eb77941..51d49e56d 100644
--- a/README.md
+++ b/README.md
@@ -75,6 +75,7 @@ volumes:
| `KANEO_API_URL` | The URL of the API |
| `JWT_ACCESS` | Secret key for generating JWT tokens |
| `DB_PATH` | The path to the database file |
+| `ALLOW_REGISTRATION` | Enable/disable new user registration (default: true) |
## 🚢 Kubernetes Deployment
@@ -206,20 +207,6 @@ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) f
- [GitHub Issues](https://github.com/usekaneo/kaneo/issues) - Report bugs or suggest features
- [Website](https://kaneo.app) - Official website
-## ❤️ Contributors & Supporters
-
-Thank you to all the contributors and sponsors who have helped make Kaneo better! 💖
-
-### Contributors
-
-<a href="https://github.com/usekaneo/kaneo/graphs/contributors">
- <img src="https://contrib.rocks/image?repo=usekaneo/kaneo" alt="Contributors" />
-</a>
-
-### Sponsors
-
-<!-- sponsors --><a href="https://github.com/alexgutjahr"><img src="https:&#x2F;&#x2F;github.com&#x2F;alexgutjahr.png" width="60px" alt="User avatar: Alex Gutjahr" /></a><!-- sponsors -->
-
## 📝 License
This project is licensed under the [MIT License](LICENSE).
diff --git a/apps/api/src/user/controllers/sign-up.ts b/apps/api/src/user/controllers/sign-up.ts
index 97b36c102..ab97c5dfe 100644
--- a/apps/api/src/user/controllers/sign-up.ts
+++ b/apps/api/src/user/controllers/sign-up.ts
@@ -1,8 +1,15 @@
import db from "../../database";
import { userTable } from "../../database/schema";
import { publishEvent } from "../../events";
+import getSettings from "../../utils/get-settings";
async function signUp(email: string, password: string, name: string) {
+ const { allowRegistration, isDemoMode } = getSettings();
+
+ if (!allowRegistration && !isDemoMode) {
+ throw new Error("Registration is disabled on this instance");
+ }
+
const isEmailTaken = Boolean(
await db.query.userTable.findFirst({
where: (users, { eq }) => eq(users.email, email),
diff --git a/apps/api/src/utils/get-settings.ts b/apps/api/src/utils/get-settings.ts
new file mode 100644
index 000000000..e93f23721
--- /dev/null
+++ b/apps/api/src/utils/get-settings.ts
@@ -0,0 +1,14 @@
+function getSettings() {
+ return {
+ allowRegistration:
+ typeof process.env.ALLOW_REGISTRATION === "string"
+ ? process.env.ALLOW_REGISTRATION === "true"
+ : true,
+ isDemoMode:
+ typeof process.env.DEMO_MODE === "string"
+ ? process.env.DEMO_MODE === "true"
+ : false,
+ };
+}
+
+export default getSettings;
diff --git a/apps/web/src/components/auth/sign-up-form.tsx b/apps/web/src/components/auth/sign-up-form.tsx
index 56492d703..8f4c16307 100644
--- a/apps/web/src/components/auth/sign-up-form.tsx
+++ b/apps/web/src/components/auth/sign-up-form.tsx
@@ -14,6 +14,7 @@ import { useRouter } from "@tanstack/react-router";
import { Eye, EyeOff } from "lucide-react";
import { useState } from "react";
import { useForm } from "react-hook-form";
+import { toast } from "sonner";
import { type ZodType, z } from "zod";
import useAuth from "../providers/auth-provider/hooks/use-auth";
@@ -44,16 +45,20 @@ export function SignUpForm() {
const { mutateAsync } = useSignUp();
const onSubmit = async (data: SignUpFormValues) => {
- const { data: user } = await mutateAsync({
- email: data.email,
- name: data.name,
- password: data.password,
- });
- setUser(user);
+ try {
+ const { data: user } = await mutateAsync({
+ email: data.email,
+ name: data.name,
+ password: data.password,
+ });
+ setUser(user);
- setTimeout(() => {
- history.push("/dashboard");
- }, 500);
+ setTimeout(() => {
+ history.push("/dashboard");
+ }, 500);
+ } catch (error) {
+ toast.error(error instanceof Error ? error.message : "Failed to sign up");
+ }
};
return (
diff --git a/charts/kaneo/README.md b/charts/kaneo/README.md
index bf7656956..a123527b1 100644
--- a/charts/kaneo/README.md
+++ b/charts/kaneo/README.md
@@ -324,3 +324,17 @@ For production deployments, consider the following security recommendations:
3. Enable and set resource limits to prevent resource exhaustion
4. Use a dedicated storage class for the SQLite database
5. Consider using a network policy to restrict traffic between components
+
+### Registration Control
+
+By default, user registration is enabled. To disable new user registration:
+
+```yaml
+api:
+ env:
+ allowRegistration: false
+```
+
+This will prevent new users from registering while still allowing existing users to log in. The registration option will be hidden from the login page.
+
+Note: This setting is ignored in demo mode where registration remains enabled.
diff --git a/charts/kaneo/templates/deployment.yaml b/charts/kaneo/templates/deployment.yaml
index e2ba1bd20..6dc7a8853 100644
--- a/charts/kaneo/templates/deployment.yaml
+++ b/charts/kaneo/templates/deployment.yaml
@@ -45,6 +45,8 @@ spec:
{{- end }}
- name: DB_PATH
value: "{{ .Values.api.persistence.mountPath }}/{{ .Values.api.persistence.dbFilename }}"
+ - name: ALLOW_REGISTRATION
+ value: {{ .Values.api.env.allowRegistration | quote }}
livenessProbe:
{{- toYaml .Values.api.livenessProbe | nindent 12 }}
readinessProbe:
diff --git a/charts/kaneo/values.yaml b/charts/kaneo/values.yaml
index 882d2f100..c11a4b191 100644
--- a/charts/kaneo/values.yaml
+++ b/charts/kaneo/values.yaml
@@ -55,6 +55,7 @@ api:
enabled: false
name: ""
key: "jwt-access"
+ allowRegistration: true
# SQLite data persistence
persistence:
diff --git a/compose.demo.yml b/compose.demo.yml
index 5dbe17299..d333ad1b6 100644
--- a/compose.demo.yml
+++ b/compose.demo.yml
@@ -37,7 +37,7 @@ services:
DB_PATH: "/app/apps/api/data/kaneo.db"
DEMO_MODE: "true"
volumes:
- - sqlite_data:/app/apps/api/data:rw
+ - sqlite_data:/app/apps/api/data
networks:
- traefik-net
restart: unless-stopped