⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
TypeScript agenticagileai-agentsbug-reportingbug-trackerganttissue-trackerjirajira-alternativekanbanlinearlinear-alternativeopen-sourceproduct-managementproject-managementroadmapself-hostedsprint-planningteam-collaborationtrello-alternative
feat: open sign-up on a fresh instance and offer a data reset in setup (#410)
Croff1a743218fd0f
diff --git a/apps/api/src/__tests__/integration/auth-config.test.ts b/apps/api/src/__tests__/integration/auth-config.test.tsnew file mode 100644index 00000000..b5ddb95f--- /dev/null+++ b/apps/api/src/__tests__/integration/auth-config.test.ts@@ -0,0 +1,16 @@+import { beforeEach, describe, expect, it } from 'bun:test';+import { api } from '../helpers/app';+import { signUpTestUser } from '../helpers/auth';+import { resetDb } from '../helpers/db';++describe('auth config', () => {+ beforeEach(resetDb);++ it('reports whether any account exists', async () => {+ expect((await api['auth-config'].get()).data).toMatchObject({ hasUsers: false });++ await signUpTestUser();++ expect((await api['auth-config'].get()).data).toMatchObject({ hasUsers: true });+ });+});diff --git a/apps/api/src/app.ts b/apps/api/src/app.tsindex 5906130b..dbed49ee 100644--- a/apps/api/src/app.ts+++ b/apps/api/src/app.ts@@ -9,7 +9,7 @@ import {hasConfiguredOidc,getOidcLabel,} from '@repo/auth';-import { hasConfiguredEmailProvider } from '@repo/db';+import { db, hasConfiguredEmailProvider, user } from '@repo/db';import { cors } from '@elysiajs/cors';import { swagger } from '@elysiajs/swagger';import { Elysia } from 'elysia';@@ -283,6 +283,7 @@ export const app = new Elysia()// Names the operator's own identity provider, so the button shows it as// given. Empty falls back to a translated default.oidcLabel: await getOidcLabel(),+ hasUsers: (await db.$count(user)) > 0,};},{diff --git a/apps/web/messages/ar/auth.json b/apps/web/messages/ar/auth.jsonindex 770eea38..8b96181c 100644--- a/apps/web/messages/ar/auth.json+++ b/apps/web/messages/ar/auth.json@@ -45,6 +45,7 @@"title": "أنشئ حسابك","subtitle": "اعمل حساب ببريدك وكلمة مرورك","subtitleInviteOnly": "النسخة دي بالدعوة بس. استخدم العنوان اللي اتدعيت بيه.",+ "subtitleFirstRun": "هذه نسخة جديدة. يصبح أول حساب هو مدير النسخة.","submit": "إنشاء حساب","submitPending": "جارٍ إنشاء الحساب…","or": "أو",diff --git a/apps/web/messages/en/auth.json b/apps/web/messages/en/auth.jsonindex 2d176e06..2ee87df2 100644--- a/apps/web/messages/en/auth.json+++ b/apps/web/messages/en/auth.json@@ -45,6 +45,7 @@"title": "Create your account","subtitle": "Sign up with your email and password","subtitleInviteOnly": "This instance is invite only. Use the address you were invited with.",+ "subtitleFirstRun": "This is a new instance. The first account becomes its administrator.","submit": "Create account","submitPending": "Creating account…","or": "Or",diff --git a/apps/web/messages/es-ES/auth.json b/apps/web/messages/es-ES/auth.jsonindex 61e0dc85..7f2ac819 100644--- a/apps/web/messages/es-ES/auth.json+++ b/apps/web/messages/es-ES/auth.json@@ -45,6 +45,7 @@"title": "Crea tu cuenta","subtitle": "Regístrate con tu correo y contraseña","subtitleInviteOnly": "Esta instancia es solo con invitación. Usa la dirección con la que te han invitado.",+ "subtitleFirstRun": "Esta instancia es nueva. La primera cuenta se convierte en su administrador.","submit": "Crear cuenta","submitPending": "Creando cuenta…","or": "O",diff --git a/apps/web/messages/fr/auth.json b/apps/web/messages/fr/auth.jsonindex 0c39bbbe..605b1d4d 100644--- a/apps/web/messages/fr/auth.json+++ b/apps/web/messages/fr/auth.json@@ -45,6 +45,7 @@"title": "Créez votre compte","subtitle": "Inscrivez-vous avec votre e-mail et un mot de passe","subtitleInviteOnly": "Cette instance est accessible sur invitation uniquement. Utilisez l'adresse avec laquelle vous avez été invité.",+ "subtitleFirstRun": "Cette instance est nouvelle. Le premier compte en devient l'administrateur.","submit": "Créer le compte","submitPending": "Création du compte…","or": "Ou",diff --git a/apps/web/messages/id/auth.json b/apps/web/messages/id/auth.jsonindex 4bed90ca..fe3ed45d 100644--- a/apps/web/messages/id/auth.json+++ b/apps/web/messages/id/auth.json@@ -45,6 +45,7 @@"title": "Buat akun Anda","subtitle": "Daftar dengan email dan kata sandi Anda","subtitleInviteOnly": "Instance ini hanya untuk undangan. Gunakan alamat email yang digunakan saat Anda menerima undangan.",+ "subtitleFirstRun": "Ini instans baru. Akun pertama menjadi administratornya.","submit": "Buat akun","submitPending": "Membuat akun…","or": "Atau",diff --git a/apps/web/messages/pt-BR/auth.json b/apps/web/messages/pt-BR/auth.jsonindex 7c0b547b..ccc9f7fe 100644--- a/apps/web/messages/pt-BR/auth.json+++ b/apps/web/messages/pt-BR/auth.json@@ -45,6 +45,7 @@"title": "Crie sua conta","subtitle": "Cadastre-se com seu e-mail e senha","subtitleInviteOnly": "Esta instância é somente por convite. Use o endereço com que você foi convidado.",+ "subtitleFirstRun": "Esta instância é nova. A primeira conta se torna seu administrador.","submit": "Criar conta","submitPending": "Criando conta…","or": "Ou",diff --git a/apps/web/messages/ru/auth.json b/apps/web/messages/ru/auth.jsonindex 979e5878..a3f534cc 100644--- a/apps/web/messages/ru/auth.json+++ b/apps/web/messages/ru/auth.json@@ -45,6 +45,7 @@"title": "Создайте аккаунт","subtitle": "Зарегистрируйтесь с почтой и паролем","subtitleInviteOnly": "Этот инстанс работает только по приглашениям. Используйте адрес, на который вас пригласили.",+ "subtitleFirstRun": "Это новый экземпляр. Первая учётная запись становится его администратором.","submit": "Создать аккаунт","submitPending": "Создание аккаунта…","or": "Или",diff --git a/apps/web/messages/uk/auth.json b/apps/web/messages/uk/auth.jsonindex 4aa99ec4..226ef769 100644--- a/apps/web/messages/uk/auth.json+++ b/apps/web/messages/uk/auth.json@@ -45,6 +45,7 @@"title": "Створіть акаунт","subtitle": "Зареєструйтеся з поштою і паролем","subtitleInviteOnly": "Цей інстанс лише за запрошеннями. Використайте адресу, на яку вас запросили.",+ "subtitleFirstRun": "Це новий екземпляр. Перший обліковий запис стає його адміністратором.","submit": "Створити акаунт","submitPending": "Створення акаунта…","or": "Або",diff --git a/apps/web/messages/zh-CN/auth.json b/apps/web/messages/zh-CN/auth.jsonindex e43fdf25..c3522c9a 100644--- a/apps/web/messages/zh-CN/auth.json+++ b/apps/web/messages/zh-CN/auth.json@@ -45,6 +45,7 @@"title": "创建账户","subtitle": "使用邮箱和密码注册","subtitleInviteOnly": "此实例仅限受邀用户注册,请使用收到邀请的邮箱。",+ "subtitleFirstRun": "这是一个新实例。第一个账号将成为它的管理员。","submit": "创建账户","submitPending": "正在创建账户…","or": "或",diff --git a/apps/web/src/features/auth/components/login/AuthLoginForm.tsx b/apps/web/src/features/auth/components/login/AuthLoginForm.tsxindex 4055ab38..a0bd5dec 100644--- a/apps/web/src/features/auth/components/login/AuthLoginForm.tsx+++ b/apps/web/src/features/auth/components/login/AuthLoginForm.tsx@@ -1,8 +1,8 @@'use client';-import { useState, type FormEvent } from 'react';+import { useEffect, useState, type FormEvent } from 'react';import Link from 'next/link';-import { useSearchParams } from 'next/navigation';+import { useRouter, useSearchParams } from 'next/navigation';import { useTranslations } from 'next-intl';import { Button } from '@/components/ui/button';import {@@ -70,6 +70,12 @@ export default function AuthLoginForm() {// the success line only stands while there is no error next to it.const justVerified = params.get('verified') === '1' && !redirectError;+ const router = useRouter();+ // A fresh instance has nobody to sign in: the first account is created on sign-up.+ useEffect(() => {+ if (authConfig?.hasUsers === false) router.replace('/register');+ }, [authConfig?.hasUsers, router]);+function switchTo(next: Method) {setMethod(next);setError(null);diff --git a/apps/web/src/features/auth/components/register/AuthRegisterForm.tsx b/apps/web/src/features/auth/components/register/AuthRegisterForm.tsxindex 8ee6dec1..ac241b36 100644--- a/apps/web/src/features/auth/components/register/AuthRegisterForm.tsx+++ b/apps/web/src/features/auth/components/register/AuthRegisterForm.tsx@@ -28,6 +28,7 @@ export default function AuthRegisterForm() {const { error, pending, setError, run } = useAuthAction();const authConfig = useAuthConfig();const inviteOnly = authConfig?.registration === 'invite';+ const firstRun = authConfig?.hasUsers === false;const needsConfirmation = authConfig?.requireEmailVerification === true;// With the password form off, the identity provider is what creates the account,// so this screen keeps only the buttons that start that round trip.@@ -89,6 +90,7 @@ export default function AuthRegisterForm() {}function subtitle() {+ if (firstRun) return t('register.subtitleFirstRun');if (!passwordEnabled) return t('register.subtitleSso');if (inviteOnly) return t('register.subtitleInviteOnly');return t('register.subtitle');@@ -132,12 +134,14 @@ export default function AuthRegisterForm() {</>)}- <FieldDescription className="text-center">- {t('register.haveAccount')}{' '}- <Link href="/login" className="underline underline-offset-4">- {t('register.signIn')}- </Link>- </FieldDescription>+ {!firstRun && (+ <FieldDescription className="text-center">+ {t('register.haveAccount')}{' '}+ <Link href="/login" className="underline underline-offset-4">+ {t('register.signIn')}+ </Link>+ </FieldDescription>+ )}</FieldGroup></form>);diff --git a/apps/web/src/lib/api/endpoints/settings.ts b/apps/web/src/lib/api/endpoints/settings.tsindex 5750c434..2d95b801 100644--- a/apps/web/src/lib/api/endpoints/settings.ts+++ b/apps/web/src/lib/api/endpoints/settings.ts@@ -81,6 +81,7 @@ export interface PublicAuthConfig {// The sign-in button text the operator gave their identity provider. Empty when// OIDC is not offered, or when they left it blank.oidcLabel: string;+ hasUsers: boolean;}// Project settings: MCP reachability and the enabled sections. Owner-only; thediff --git a/scripts/setup.ts b/scripts/setup.tsindex 0148bccf..82a247ff 100644--- a/scripts/setup.ts+++ b/scripts/setup.ts@@ -270,8 +270,32 @@ if (mode === 'env') {if (mode === 'try') {const compose = ['docker', 'compose'];+ const TRY_VOLUME = 'itsaplan_postgres-data';await stopOther(['docker', 'compose', '-f', 'docker-compose.dev.yml'], 'Develop');+ // Before writeSecrets, which generates new secrets only while the volume is absent.+ if (await volumeExists(TRY_VOLUME)) {+ const wipe = answer(+ await p.select({+ message: 'This instance already has data.',+ options: [+ { value: false, label: 'Keep it', hint: 'the existing accounts and projects stay' },+ {+ value: true,+ label: 'Start fresh',+ hint: 'the database and every uploaded file are deleted',+ },+ ],+ }),+ );+ if (wipe) {+ const wiping = p.spinner();+ wiping.start('Deleting the data');+ await run(...compose, 'down', '-v');+ wiping.stop('Data deleted');+ }+ }+const running = await isUp(compose);if (running) {@@ -291,7 +315,7 @@ if (mode === 'try') {env.set('WEB_PORT', String(webPort));env.set('API_URL', `http://localhost:${apiPort}`);env.set('APP_URL', `http://localhost:${webPort}`);- await writeSecrets(env, 'itsaplan_postgres-data');+ await writeSecrets(env, TRY_VOLUME);env.save();}