forge
Explore
Log in

Don't you dare go Hollow

✨ school identity is the uuid

Browse files at this commit

a3eb98c6c92d543d92e6ec2187f308002f1e3bb5Ahmet Kaan GümüşParent: a72b005
  • feat
    • ✨ school identity is the uuid
Show full message
feat: ✨ school identity is the uuid

- register picks an active school from GET /auth/schools; an empty list disables submit
- builder routes, list, and school API calls use the school id
- slug field, slug limits, and the slug-collision error are gone
README.mdmodified+1 -1
@@ -53,7 +53,7 @@ Open [http://localhost:5173](http://localhost:5173) in your browser.
53 53
54 > **Proxy Note**: Vite proxies `/api/*` and WebSocket connections to `BACKEND_ORIGIN`, preserving HttpOnly session cookies across same-origin calls. Local development defaults to `https://hezarfen-backend.dizey.sh`, so `bun run dev` works without a backend process on the laptop; use `BACKEND_ORIGIN=http://127.0.0.1:7656 bun run dev` to target one locally. The production Bun server gets its co-located loopback default from the image and can be overridden through `hezarfen_frontend.env` (see "Run in a container" below).54 > **Proxy Note**: Vite proxies `/api/*` and WebSocket connections to `BACKEND_ORIGIN`, preserving HttpOnly session cookies across same-origin calls. Local development defaults to `https://hezarfen-backend.dizey.sh`, so `bun run dev` works without a backend process on the laptop; use `BACKEND_ORIGIN=http://127.0.0.1:7656 bun run dev` to target one locally. The production Bun server gets its co-located loopback default from the image and can be overridden through `hezarfen_frontend.env` (see "Run in a container" below).
55 55
56-> **Dev auto sign-in**: for local testing, put `VITE_DEV_AUTOLOGIN_USERNAME` and `VITE_DEV_AUTOLOGIN_PASSWORD` (optionally `VITE_DEV_AUTOLOGIN_SCHOOL`, a school slug) in `.env.local`, which git ignores. `bun run dev` then signs in on the first `401`; logging out turns it off for that tab. It lives in `src/lib/dev-auto-login.ts` behind `import.meta.env.DEV`, so `vite build` drops it and the credentials never reach `dist/`.56+> **Dev auto sign-in**: for local testing, put `VITE_DEV_AUTOLOGIN_USERNAME` and `VITE_DEV_AUTOLOGIN_PASSWORD` (optionally `VITE_DEV_AUTOLOGIN_SCHOOL`, a school uuid) in `.env.local`, which git ignores. `bun run dev` then signs in on the first `401`; logging out turns it off for that tab. It lives in `src/lib/dev-auto-login.ts` behind `import.meta.env.DEV`, so `vite build` drops it and the credentials never reach `dist/`.
57 57
58 > **Demo sign-in**: set `VITE_DEMO_LOGIN_USERNAME` and `VITE_DEMO_LOGIN_PASSWORD` at build time and the login page opens filled with them, plus a one-click "Demo hesabıyla gir" button (`src/lib/demo-login.ts`). Unlike the dev auto sign-in these values are bundled into `dist/`, so set them only for a demo school's build.58 > **Demo sign-in**: set `VITE_DEMO_LOGIN_USERNAME` and `VITE_DEMO_LOGIN_PASSWORD` at build time and the login page opens filled with them, plus a one-click "Demo hesabıyla gir" button (`src/lib/demo-login.ts`). Unlike the dev auto sign-in these values are bundled into `dist/`, so set them only for a demo school's build.
59 59
docs/auth/role-scope-matrix.mdmodified+1 -1
@@ -47,7 +47,7 @@ route and a school session is 401 here, so these pages carry their own
47 |---|---|47 |---|---|
48 | `/builder/login` | Operator sign-in (linked from the school login footer) |48 | `/builder/login` | Operator sign-in (linked from the school login footer) |
49 | `/builder` | School list: create (with first admin + module set), suspend/activate, delete |49 | `/builder` | School list: create (with first admin + module set), suspend/activate, delete |
50-| `/builder/schools/:slug` | Rename/status, module switchboard (per module + per package), admin password reset, enter as admin |50+| `/builder/schools/:id` | Rename/status, module switchboard (per module + per package), admin password reset, enter as admin |
51 51
52 ## Primary Navigation per Role52 ## Primary Navigation per Role
53 53
docs/ui/figma-migration-coverage.mdmodified+1 -1
@@ -162,7 +162,7 @@ Rules the captures follow:
162 | `/profile/:userId` | ADM-29 Kullanıcı Profili | Captured from the running app |162 | `/profile/:userId` | ADM-29 Kullanıcı Profili | Captured from the running app |
163 | `/builder/login` | BLD-01 Operatör Girişi | Builder session only; linked from the SYS-01/login footer |163 | `/builder/login` | BLD-01 Operatör Girişi | Builder session only; linked from the SYS-01/login footer |
164 | `/builder` | BLD-02 Okullar, BLD-02a Yeni Okul | Create, suspend/activate, delete |164 | `/builder` | BLD-02 Okullar, BLD-02a Yeni Okul | Create, suspend/activate, delete |
165-| `/builder/schools/:slug` | BLD-03 Okul Detayı, BLD-03a Okula Gir | Module switchboard, password reset, enter as admin |165+| `/builder/schools/:id` | BLD-03 Okul Detayı, BLD-03a Okula Gir | Module switchboard, password reset, enter as admin |
166 166
167 ## Figma features blocked by product or backend scope167 ## Figma features blocked by product or backend scope
168 168
e2e/auth-shell.spec.tsmodified+9 -2
@@ -1,17 +1,24 @@
1 import { expect, test } from "@playwright/test";1 import { expect, test } from "@playwright/test";
2 2
3-const school = process.env.E2E_SCHOOL_SLUG ?? "demo";3+const schoolId = process.env.E2E_SCHOOL_ID;
4 const username = process.env.E2E_ADMIN_USERNAME ?? "admin";4 const username = process.env.E2E_ADMIN_USERNAME ?? "admin";
5 const password = process.env.E2E_ADMIN_PASSWORD ?? "admin123";5 const password = process.env.E2E_ADMIN_PASSWORD ?? "admin123";
6 6
7 test("sign-in reaches the authenticated shell with keyboard-accessible navigation", async ({ page }) => {7 test("sign-in reaches the authenticated shell with keyboard-accessible navigation", async ({ page }) => {
8 await page.goto("/login");8 await page.goto("/login");
9 await expect(page.locator("#login-username")).toBeVisible();9 await expect(page.locator("#login-username")).toBeVisible();
10- await page.locator("#login-school").fill(school);
11 await page.locator("#login-username").fill(username);10 await page.locator("#login-username").fill(username);
12 await page.locator("#login-password").fill(password);11 await page.locator("#login-password").fill(password);
13 await page.locator("form").getByRole("button", { name: /log in|sign in|giriş yap/i }).click();12 await page.locator("form").getByRole("button", { name: /log in|sign in|giriş yap/i }).click();
14 13
14+ const chooser = page.getByRole("heading", { name: /choose your school|okulunu seç/i });
15+ const shell = page.getByRole("main");
16+ await expect(chooser.or(shell)).toBeVisible();
17+ if (await chooser.isVisible()) {
18+ if (!schoolId) throw new Error("login returned a school chooser; set E2E_SCHOOL_ID to the school uuid");
19+ await page.getByRole("button", { name: schoolId }).click();
20+ }
21+
15 await expect(page).toHaveURL(/\/$/);22 await expect(page).toHaveURL(/\/$/);
16 await expect(page.getByRole("main")).toBeVisible();23 await expect(page.getByRole("main")).toBeVisible();
17 24
src/api/__tests__/auth/auth.test.tsmodified+17 -3
@@ -1,4 +1,5 @@
1 import { afterEach, describe, expect, it, vi } from "vitest";1 import { afterEach, describe, expect, it, vi } from "vitest";
2+import { getRegisterSchools } from "../../auth";
2 import { postLogin } from "../../auth";3 import { postLogin } from "../../auth";
3 import { postLogout } from "../../auth";4 import { postLogout } from "../../auth";
4 import { postRegister } from "../../auth";5 import { postRegister } from "../../auth";
@@ -27,13 +28,14 @@ describe("auth API", () => {
27 const mockUser = { id: "u1", username: "test" };28 const mockUser = { id: "u1", username: "test" };
28 mockFetchSuccess(mockUser);29 mockFetchSuccess(mockUser);
29 30
30- const result = await postSelectSchool({ school: "demo" });31+ const school = "019732e3-7b00-7000-8000-00000000dead";
32+ const result = await postSelectSchool({ school });
31 expect(result).toEqual(mockUser);33 expect(result).toEqual(mockUser);
32 34
33 const [url, init] = lastFetchCall();35 const [url, init] = lastFetchCall();
34 expect(url).toBe("/api/auth/school");36 expect(url).toBe("/api/auth/school");
35 expect(init?.method).toBe("POST");37 expect(init?.method).toBe("POST");
36- expect(init?.body).toBe(JSON.stringify({ school: "demo" }));38+ expect(init?.body).toBe(JSON.stringify({ school }));
37 });39 });
38 40
39 it("postLogout calls /auth/logout", async () => {41 it("postLogout calls /auth/logout", async () => {
@@ -50,7 +52,7 @@ describe("auth API", () => {
50 const mockResponse = { username: "newuser", role: "student" };52 const mockResponse = { username: "newuser", role: "student" };
51 mockFetchSuccess(mockResponse);53 mockFetchSuccess(mockResponse);
52 54
53- const data = { school: "demo", username: "newuser", password: "password" };55+ const data = { school: "019732e3-7b00-7000-8000-00000000dead", username: "newuser", password: "password" };
54 const result = await postRegister(data);56 const result = await postRegister(data);
55 expect(result).toEqual(mockResponse);57 expect(result).toEqual(mockResponse);
56 58
@@ -59,4 +61,16 @@ describe("auth API", () => {
59 expect(init?.method).toBe("POST");61 expect(init?.method).toBe("POST");
60 expect(init?.body).toBe(JSON.stringify(data));62 expect(init?.body).toBe(JSON.stringify(data));
61 });63 });
64+
65+ it("getRegisterSchools reads active schools for the register picker", async () => {
66+ const schools = [{ id: "019732e3-7b00-7000-8000-00000000dead", name: "Hezarfen" }];
67+ mockFetchSuccess(schools);
68+
69+ const result = await getRegisterSchools();
70+ expect(result).toEqual(schools);
71+
72+ const [url, init] = lastFetchCall();
73+ expect(url).toBe("/api/auth/schools");
74+ expect(init?.method).toBe("GET");
75+ });
62 });76 });
src/api/__tests__/contract/helpers/live-client.tsmodified+18 -4
@@ -21,6 +21,20 @@ const TIMEOUT_MS = 10_000;
21 const MAX_RATE_LIMIT_RETRIES = 12;21 const MAX_RATE_LIMIT_RETRIES = 12;
22 let cookie = "";22 let cookie = "";
23 23
24+const SCHOOL_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
25+
26+/** School cookie is `session=<uuid>.<token>`; operator cookie stays `session=builder.<token>`. */
27+function sessionCookie(raw: string): string | null {
28+ const pair = raw.split(";")[0] ?? "";
29+ if (!pair.startsWith("session=")) return null;
30+ const value = pair.slice("session=".length);
31+ const dot = value.indexOf(".");
32+ if (dot <= 0 || dot === value.length - 1) return null;
33+ const prefix = value.slice(0, dot);
34+ if (prefix === "builder" || SCHOOL_UUID.test(prefix)) return pair;
35+ return null;
36+}
37+
24 type Init = { method?: string; body?: unknown; headers?: Record<string, string> };38 type Init = { method?: string; body?: unknown; headers?: Record<string, string> };
25 39
26 function retryDelayMs(response: Response, attempt: number): number {40 function retryDelayMs(response: Response, attempt: number): number {
@@ -59,8 +73,8 @@ export async function api(path: string, init: Init = {}): Promise<Response> {
59 73
60 const setCookies = res!.headers.getSetCookie?.() ?? [];74 const setCookies = res!.headers.getSetCookie?.() ?? [];
61 for (const raw of setCookies) {75 for (const raw of setCookies) {
62- const pair = raw.split(";")[0];76+ const pair = sessionCookie(raw);
63- if (pair.startsWith("session=")) cookie = pair;77+ if (pair) cookie = pair;
64 }78 }
65 return res!;79 return res!;
66 }80 }
@@ -77,7 +91,7 @@ export async function json<T>(path: string, init: Init = {}): Promise<T> {
77 91
78 /** Log in as the seeded admin; the session cookie lands in the jar. */92 /** Log in as the seeded admin; the session cookie lands in the jar. */
79 export async function loginAdmin(): Promise<void> {93 export async function loginAdmin(): Promise<void> {
80- const result = await json<{ id: string } | { schools: Array<{ slug: string }> }>("/auth/login", {94+ const result = await json<{ id: string } | { schools: Array<{ id: string }> }>("/auth/login", {
81 method: "POST",95 method: "POST",
82 body: {96 body: {
83 username: env.ADMIN_USERNAME ?? "admin",97 username: env.ADMIN_USERNAME ?? "admin",
@@ -85,7 +99,7 @@ export async function loginAdmin(): Promise<void> {
85 },99 },
86 });100 });
87 if ("schools" in result) {101 if ("schools" in result) {
88- const school = env.SCHOOL_SLUG ?? result.schools[0]?.slug;102+ const school = env.SCHOOL_ID ?? result.schools[0]?.id;
89 if (!school) throw new Error("POST /auth/login returned an empty school choice list");103 if (!school) throw new Error("POST /auth/login returned an empty school choice list");
90 await json("/auth/school", { method: "POST", body: { school } });104 await json("/auth/school", { method: "POST", body: { school } });
91 }105 }
src/api/__tests__/schools/schools.test.tsmodified+27 -26
@@ -1,10 +1,10 @@
1 import { afterEach, describe, expect, it, vi } from "vitest";1 import { afterEach, describe, expect, it, vi } from "vitest";
2-import { deleteSchoolBySlug } from "../../schools";2+import { deleteSchool } from "../../schools";
3 import { deleteSchoolModule } from "../../schools";3 import { deleteSchoolModule } from "../../schools";
4-import { getSchoolBySlug } from "../../schools";4+import { getSchool } from "../../schools";
5 import { getSchoolModules } from "../../schools";5 import { getSchoolModules } from "../../schools";
6 import { getSchools } from "../../schools";6 import { getSchools } from "../../schools";
7-import { patchSchoolBySlug } from "../../schools";7+import { patchSchool } from "../../schools";
8 import { patchSchoolModules } from "../../schools";8 import { patchSchoolModules } from "../../schools";
9 import { postSchool } from "../../schools";9 import { postSchool } from "../../schools";
10 import { postSchoolAdminPassword } from "../../schools";10 import { postSchoolAdminPassword } from "../../schools";
@@ -12,7 +12,8 @@ import { postSchoolEnter } from "../../schools";
12 import { postSchoolModule } from "../../schools";12 import { postSchoolModule } from "../../schools";
13 import { lastFetchCall, mockFetch204, mockFetchSuccess } from "../helpers/mock-fetch";13 import { lastFetchCall, mockFetch204, mockFetchSuccess } from "../helpers/mock-fetch";
14 14
15-const school = { slug: "ata-koleji", name: "Ata Koleji", status: "active", created_at: 1, modules: ["courses"] };15+const schoolId = "019732e3-7b00-7000-8000-00000000dead";
16+const school = { id: schoolId, name: "Ata Koleji", status: "active", created_at: 1, modules: ["courses"] };
16 const modules = { enabled: ["courses"], disabled: ["exams"] };17 const modules = { enabled: ["courses"], disabled: ["exams"] };
17 18
18 describe("schools API", () => {19 describe("schools API", () => {
@@ -31,19 +32,19 @@ describe("schools API", () => {
31 expect(init?.method).toBe("GET");32 expect(init?.method).toBe("GET");
32 });33 });
33 34
34- it("getSchoolBySlug reads /schools/{slug}", async () => {35+ it("getSchool reads /schools/{id}", async () => {
35 mockFetchSuccess(school);36 mockFetchSuccess(school);
36 37
37- await getSchoolBySlug("ata-koleji");38+ await getSchool(schoolId);
38 39
39 const [url, init] = lastFetchCall();40 const [url, init] = lastFetchCall();
40- expect(url).toBe("/api/schools/ata-koleji");41+ expect(url).toBe(`/api/schools/${schoolId}`);
41 expect(init?.method).toBe("GET");42 expect(init?.method).toBe("GET");
42 });43 });
43 44
44 it("postSchool posts the school and its first admin", async () => {45 it("postSchool posts the school and its first admin", async () => {
45 mockFetchSuccess(school, 201);46 mockFetchSuccess(school, 201);
46- const body = { slug: "ata-koleji", name: "Ata Koleji", admin_username: "admin", admin_password: "secret123", modules: ["courses"] };47+ const body = { name: "Ata Koleji", admin_username: "admin", admin_password: "secret123", modules: ["courses"] };
47 48
48 await postSchool(body);49 await postSchool(body);
49 50
@@ -53,34 +54,34 @@ describe("schools API", () => {
53 expect(init?.body).toBe(JSON.stringify(body));54 expect(init?.body).toBe(JSON.stringify(body));
54 });55 });
55 56
56- it("patchSchoolBySlug patches name and status", async () => {57+ it("patchSchool patches name and status", async () => {
57 mockFetchSuccess({ ...school, status: "suspended" });58 mockFetchSuccess({ ...school, status: "suspended" });
58 59
59- await patchSchoolBySlug("ata-koleji", { status: "suspended" });60+ await patchSchool(schoolId, { status: "suspended" });
60 61
61 const [url, init] = lastFetchCall();62 const [url, init] = lastFetchCall();
62- expect(url).toBe("/api/schools/ata-koleji");63+ expect(url).toBe(`/api/schools/${schoolId}`);
63 expect(init?.method).toBe("PATCH");64 expect(init?.method).toBe("PATCH");
64 expect(init?.body).toBe(JSON.stringify({ status: "suspended" }));65 expect(init?.body).toBe(JSON.stringify({ status: "suspended" }));
65 });66 });
66 67
67- it("deleteSchoolBySlug deletes /schools/{slug}", async () => {68+ it("deleteSchool deletes /schools/{id}", async () => {
68 mockFetch204();69 mockFetch204();
69 70
70- await deleteSchoolBySlug("ata-koleji");71+ await deleteSchool(schoolId);
71 72
72 const [url, init] = lastFetchCall();73 const [url, init] = lastFetchCall();
73- expect(url).toBe("/api/schools/ata-koleji");74+ expect(url).toBe(`/api/schools/${schoolId}`);
74 expect(init?.method).toBe("DELETE");75 expect(init?.method).toBe("DELETE");
75 });76 });
76 77
77 it("postSchoolAdminPassword re-keys an admin", async () => {78 it("postSchoolAdminPassword re-keys an admin", async () => {
78 mockFetch204();79 mockFetch204();
79 80
80- await postSchoolAdminPassword("ata-koleji", { username: "admin", password: "newsecret" });81+ await postSchoolAdminPassword(schoolId, { username: "admin", password: "newsecret" });
81 82
82 const [url, init] = lastFetchCall();83 const [url, init] = lastFetchCall();
83- expect(url).toBe("/api/schools/ata-koleji/admin-password");84+ expect(url).toBe(`/api/schools/${schoolId}/admin-password`);
84 expect(init?.method).toBe("POST");85 expect(init?.method).toBe("POST");
85 expect(init?.body).toBe(JSON.stringify({ username: "admin", password: "newsecret" }));86 expect(init?.body).toBe(JSON.stringify({ username: "admin", password: "newsecret" }));
86 });87 });
@@ -88,10 +89,10 @@ describe("schools API", () => {
88 it("postSchoolEnter enters as a named admin", async () => {89 it("postSchoolEnter enters as a named admin", async () => {
89 mockFetchSuccess({ id: "u1", username: "admin", role: "admin" });90 mockFetchSuccess({ id: "u1", username: "admin", role: "admin" });
90 91
91- await postSchoolEnter("ata-koleji", { username: "admin" });92+ await postSchoolEnter(schoolId, { username: "admin" });
92 93
93 const [url, init] = lastFetchCall();94 const [url, init] = lastFetchCall();
94- expect(url).toBe("/api/schools/ata-koleji/enter");95+ expect(url).toBe(`/api/schools/${schoolId}/enter`);
95 expect(init?.method).toBe("POST");96 expect(init?.method).toBe("POST");
96 expect(init?.body).toBe(JSON.stringify({ username: "admin" }));97 expect(init?.body).toBe(JSON.stringify({ username: "admin" }));
97 });98 });
@@ -99,11 +100,11 @@ describe("schools API", () => {
99 it("getSchoolModules reads both halves of the catalog", async () => {100 it("getSchoolModules reads both halves of the catalog", async () => {
100 mockFetchSuccess(modules);101 mockFetchSuccess(modules);
101 102
102- const result = await getSchoolModules("ata-koleji");103+ const result = await getSchoolModules(schoolId);
103 expect(result).toEqual(modules);104 expect(result).toEqual(modules);
104 105
105 const [url, init] = lastFetchCall();106 const [url, init] = lastFetchCall();
106- expect(url).toBe("/api/schools/ata-koleji/modules");107+ expect(url).toBe(`/api/schools/${schoolId}/modules`);
107 expect(init?.method).toBe("GET");108 expect(init?.method).toBe("GET");
108 });109 });
109 110
@@ -111,10 +112,10 @@ describe("schools API", () => {
111 mockFetchSuccess(modules);112 mockFetchSuccess(modules);
112 const body = { enable: ["exams"], disable_packages: ["ai"] };113 const body = { enable: ["exams"], disable_packages: ["ai"] };
113 114
114- await patchSchoolModules("ata-koleji", body);115+ await patchSchoolModules(schoolId, body);
115 116
116 const [url, init] = lastFetchCall();117 const [url, init] = lastFetchCall();
117- expect(url).toBe("/api/schools/ata-koleji/modules");118+ expect(url).toBe(`/api/schools/${schoolId}/modules`);
118 expect(init?.method).toBe("PATCH");119 expect(init?.method).toBe("PATCH");
119 expect(init?.body).toBe(JSON.stringify(body));120 expect(init?.body).toBe(JSON.stringify(body));
120 });121 });
@@ -122,20 +123,20 @@ describe("schools API", () => {
122 it("postSchoolModule enables one module", async () => {123 it("postSchoolModule enables one module", async () => {
123 mockFetchSuccess(modules);124 mockFetchSuccess(modules);
124 125
125- await postSchoolModule("ata-koleji", "exams");126+ await postSchoolModule(schoolId, "exams");
126 127
127 const [url, init] = lastFetchCall();128 const [url, init] = lastFetchCall();
128- expect(url).toBe("/api/schools/ata-koleji/modules/exams");129+ expect(url).toBe(`/api/schools/${schoolId}/modules/exams`);
129 expect(init?.method).toBe("POST");130 expect(init?.method).toBe("POST");
130 });131 });
131 132
132 it("deleteSchoolModule disables one module", async () => {133 it("deleteSchoolModule disables one module", async () => {
133 mockFetchSuccess(modules);134 mockFetchSuccess(modules);
134 135
135- await deleteSchoolModule("ata-koleji", "exams");136+ await deleteSchoolModule(schoolId, "exams");
136 137
137 const [url, init] = lastFetchCall();138 const [url, init] = lastFetchCall();
138- expect(url).toBe("/api/schools/ata-koleji/modules/exams");139+ expect(url).toBe(`/api/schools/${schoolId}/modules/exams`);
139 expect(init?.method).toBe("DELETE");140 expect(init?.method).toBe("DELETE");
140 });141 });
141 });142 });
src/api/auth/getRegisterSchools.tsadded+7 -0
@@ -0,0 +1,7 @@
1+import { client } from "../client";
2+import type { SchoolChoice } from "./postLogin";
3+
4+/** Active schools a new account can join. Unauthenticated, same as register. */
5+export function getRegisterSchools(signal?: AbortSignal): Promise<SchoolChoice[]> {
6+ return client<SchoolChoice[]>("/auth/schools", { signal });
7+}
src/api/auth/index.tsmodified+1 -0
@@ -2,3 +2,4 @@ export * from "./postLogin";
2 export * from "./postLogout";2 export * from "./postLogout";
3 export * from "./postRegister";3 export * from "./postRegister";
4 export * from "./postSelectSchool";4 export * from "./postSelectSchool";
5+export * from "./getRegisterSchools";
src/api/auth/postLogin.tsmodified+1 -1
@@ -7,7 +7,7 @@ export type LoginBody = {
7 };7 };
8 8
9 export type SchoolChoice = {9 export type SchoolChoice = {
10- slug: string;10+ id: string;
11 name: string;11 name: string;
12 };12 };
13 13
src/api/client/client.tsmodified+0 -4
@@ -133,10 +133,6 @@ const API_ERROR_MESSAGES: Record<string, Record<Locale, string>> = {
133 tr: "Tekrarlanan müsaitlikler birbiriyle çakışıyor.",133 tr: "Tekrarlanan müsaitlikler birbiriyle çakışıyor.",
134 },134 },
135 // Builder surface (web/builder.rs, tenant.rs) — byte-exact.135 // Builder surface (web/builder.rs, tenant.rs) — byte-exact.
136- "school slug already taken": {
137- en: "That school code is already taken.",
138- tr: "Bu okul kodu zaten kullanılıyor.",
139- },
140 "that account is not an admin of this school": {136 "that account is not an admin of this school": {
141 en: "That account exists but is not an admin of this school.",137 en: "That account exists but is not an admin of this school.",
142 tr: "Bu hesap var ama bu okulun yöneticisi değil.",138 tr: "Bu hesap var ama bu okulun yöneticisi değil.",
src/api/client/types.tsmodified+1 -4
@@ -188,7 +188,7 @@ export type SchoolStatus = "active" | "suspended";
188 188
189 /** One school of the deployment, as the builder surface sees it. */189 /** One school of the deployment, as the builder surface sees it. */
190 export type School = {190 export type School = {
191- slug: string;191+ id: string;
192 name: string;192 name: string;
193 /** A suspended school refuses every one of its own users, login included. */193 /** A suspended school refuses every one of its own users, login included. */
194 status: SchoolStatus;194 status: SchoolStatus;
@@ -831,11 +831,8 @@ export type Limits = {
831 max_username_len: number;831 max_username_len: number;
832 username_separators: string[];832 username_separators: string[];
833 reserved_usernames: string[];833 reserved_usernames: string[];
834- reserved_slugs: string[];
835 min_password_len: number;834 min_password_len: number;
836 max_password_len: number;835 max_password_len: number;
837- min_slug_len: number;
838- max_slug_len: number;
839 max_school_name_len: number;836 max_school_name_len: number;
840 max_name_len: number;837 max_name_len: number;
841 max_display_name_len: number;838 max_display_name_len: number;
src/api/schools/deleteSchool.tsadded+6 -0
@@ -0,0 +1,6 @@
1+import { client } from "../client";
2+
3+// Destroys the school's data and uploaded files for good.
4+export function deleteSchool(id: string): Promise<void> {
5+ return client<void>(`/schools/${encodeURIComponent(id)}`, { method: "DELETE" });
6+}
src/api/schools/deleteSchoolBySlug.tsdeleted+0 -6
@@ -1,6 +0,0 @@
1-import { client } from "../client";
2-
3-// Destroys the school's data and uploaded files for good.
4-export function deleteSchoolBySlug(slug: string): Promise<void> {
5- return client<void>(`/schools/${encodeURIComponent(slug)}`, { method: "DELETE" });
6-}
src/api/schools/deleteSchoolModule.tsmodified+2 -2
@@ -1,8 +1,8 @@
1 import { client } from "../client";1 import { client } from "../client";
2 import type { SchoolModules } from "../client";2 import type { SchoolModules } from "../client";
3 3
4-export function deleteSchoolModule(slug: string, module: string): Promise<SchoolModules> {4+export function deleteSchoolModule(id: string, module: string): Promise<SchoolModules> {
5- return client<SchoolModules>(`/schools/${encodeURIComponent(slug)}/modules/${encodeURIComponent(module)}`, {5+ return client<SchoolModules>(`/schools/${encodeURIComponent(id)}/modules/${encodeURIComponent(module)}`, {
6 method: "DELETE",6 method: "DELETE",
7 });7 });
8 }8 }
src/api/schools/getSchool.tsadded+6 -0
@@ -0,0 +1,6 @@
1+import { client } from "../client";
2+import type { School } from "../client";
3+
4+export function getSchool(id: string, signal?: AbortSignal): Promise<School> {
5+ return client<School>(`/schools/${encodeURIComponent(id)}`, { signal });
6+}
src/api/schools/getSchoolBySlug.tsdeleted+0 -6
@@ -1,6 +0,0 @@
1-import { client } from "../client";
2-import type { School } from "../client";
3-
4-export function getSchoolBySlug(slug: string, signal?: AbortSignal): Promise<School> {
5- return client<School>(`/schools/${encodeURIComponent(slug)}`, { signal });
6-}
src/api/schools/getSchoolModules.tsmodified+2 -2
@@ -1,6 +1,6 @@
1 import { client } from "../client";1 import { client } from "../client";
2 import type { SchoolModules } from "../client";2 import type { SchoolModules } from "../client";
3 3
4-export function getSchoolModules(slug: string, signal?: AbortSignal): Promise<SchoolModules> {4+export function getSchoolModules(id: string, signal?: AbortSignal): Promise<SchoolModules> {
5- return client<SchoolModules>(`/schools/${encodeURIComponent(slug)}/modules`, { signal });5+ return client<SchoolModules>(`/schools/${encodeURIComponent(id)}/modules`, { signal });
6 }6 }
src/api/schools/index.tsmodified+3 -3
@@ -1,8 +1,8 @@
1 export * from "./getSchools";1 export * from "./getSchools";
2-export * from "./getSchoolBySlug";2+export * from "./getSchool";
3 export * from "./postSchool";3 export * from "./postSchool";
4-export * from "./patchSchoolBySlug";4+export * from "./patchSchool";
5-export * from "./deleteSchoolBySlug";5+export * from "./deleteSchool";
6 export * from "./postSchoolAdminPassword";6 export * from "./postSchoolAdminPassword";
7 export * from "./postSchoolEnter";7 export * from "./postSchoolEnter";
8 export * from "./getSchoolModules";8 export * from "./getSchoolModules";
src/api/schools/patchSchool.tsadded+11 -0
@@ -0,0 +1,11 @@
1+import { client } from "../client";
2+import type { School, SchoolStatus } from "../client";
3+
4+export type UpdateSchoolBody = {
5+ name?: string;
6+ status?: SchoolStatus;
7+};
8+
9+export function patchSchool(id: string, body: UpdateSchoolBody): Promise<School> {
10+ return client<School>(`/schools/${encodeURIComponent(id)}`, { method: "PATCH", body });
11+}
src/api/schools/patchSchoolBySlug.tsdeleted+0 -11
@@ -1,11 +0,0 @@
1-import { client } from "../client";
2-import type { School, SchoolStatus } from "../client";
3-
4-export type UpdateSchoolBody = {
5- name?: string;
6- status?: SchoolStatus;
7-};
8-
9-export function patchSchoolBySlug(slug: string, body: UpdateSchoolBody): Promise<School> {
10- return client<School>(`/schools/${encodeURIComponent(slug)}`, { method: "PATCH", body });
11-}
src/api/schools/patchSchoolModules.tsmodified+2 -2
@@ -9,6 +9,6 @@ export type PatchSchoolModulesBody = {
9 };9 };
10 10
11 // One atomic re-sell: a 409 names every broken dependency and nothing is written.11 // One atomic re-sell: a 409 names every broken dependency and nothing is written.
12-export function patchSchoolModules(slug: string, body: PatchSchoolModulesBody): Promise<SchoolModules> {12+export function patchSchoolModules(id: string, body: PatchSchoolModulesBody): Promise<SchoolModules> {
13- return client<SchoolModules>(`/schools/${encodeURIComponent(slug)}/modules`, { method: "PATCH", body });13+ return client<SchoolModules>(`/schools/${encodeURIComponent(id)}/modules`, { method: "PATCH", body });
14 }14 }
src/api/schools/postSchool.tsmodified+0 -2
@@ -2,8 +2,6 @@ import { client } from "../client";
2 import type { School } from "../client";2 import type { School } from "../client";
3 3
4 export type CreateSchoolBody = {4 export type CreateSchoolBody = {
5- /** Immutable once taken: names the school's database, blobs and cookie prefix. */
6- slug: string;
7 name: string;5 name: string;
8 admin_username: string;6 admin_username: string;
9 admin_password: string;7 admin_password: string;
src/api/schools/postSchoolAdminPassword.tsmodified+2 -2
@@ -6,6 +6,6 @@ export type SchoolAdminPasswordBody = {
6 };6 };
7 7
8 // Re-keys an admin of that school and revokes every session the account held.8 // Re-keys an admin of that school and revokes every session the account held.
9-export function postSchoolAdminPassword(slug: string, body: SchoolAdminPasswordBody): Promise<void> {9+export function postSchoolAdminPassword(id: string, body: SchoolAdminPasswordBody): Promise<void> {
10- return client<void>(`/schools/${encodeURIComponent(slug)}/admin-password`, { method: "POST", body });10+ return client<void>(`/schools/${encodeURIComponent(id)}/admin-password`, { method: "POST", body });
11 }11 }
src/api/schools/postSchoolEnter.tsmodified+2 -2
@@ -3,6 +3,6 @@ import type { User } from "../client";
3 3
4 // Support access: swaps the builder cookie for an ordinary session of one of4 // Support access: swaps the builder cookie for an ordinary session of one of
5 // the school's admins. Refused (403) on a suspended school.5 // the school's admins. Refused (403) on a suspended school.
6-export function postSchoolEnter(slug: string, body: { username: string }): Promise<User> {6+export function postSchoolEnter(id: string, body: { username: string }): Promise<User> {
7- return client<User>(`/schools/${encodeURIComponent(slug)}/enter`, { method: "POST", body });7+ return client<User>(`/schools/${encodeURIComponent(id)}/enter`, { method: "POST", body });
8 }8 }
src/api/schools/postSchoolModule.tsmodified+2 -2
@@ -1,8 +1,8 @@
1 import { client } from "../client";1 import { client } from "../client";
2 import type { SchoolModules } from "../client";2 import type { SchoolModules } from "../client";
3 3
4-export function postSchoolModule(slug: string, module: string): Promise<SchoolModules> {4+export function postSchoolModule(id: string, module: string): Promise<SchoolModules> {
5- return client<SchoolModules>(`/schools/${encodeURIComponent(slug)}/modules/${encodeURIComponent(module)}`, {5+ return client<SchoolModules>(`/schools/${encodeURIComponent(id)}/modules/${encodeURIComponent(module)}`, {
6 method: "POST",6 method: "POST",
7 });7 });
8 }8 }
src/components/builder/create-school-panel.tsxmodified+0 -10
@@ -13,8 +13,6 @@ import { Label } from "@/components/ui/label";
13 import { SidePanel } from "@/components/ui/side-panel";13 import { SidePanel } from "@/components/ui/side-panel";
14 import { useT } from "@/stores/preferences-context";14 import { useT } from "@/stores/preferences-context";
15 15
16-const SLUG_PATTERN = "[a-z0-9][a-z0-9-]+";
17-
18 /** Creates a school with its first admin and, optionally, a hand-picked module set. */16 /** Creates a school with its first admin and, optionally, a hand-picked module set. */
19 export function CreateSchoolPanel(props: { open: boolean; onOpenChange: (open: boolean) => void; onCreated: (school: School) => void }) {17 export function CreateSchoolPanel(props: { open: boolean; onOpenChange: (open: boolean) => void; onCreated: (school: School) => void }) {
20 const t = useT();18 const t = useT();
@@ -23,7 +21,6 @@ export function CreateSchoolPanel(props: { open: boolean; onOpenChange: (open: b
23 () => props.open || undefined,21 () => props.open || undefined,
24 () => getLimits().catch(() => null),22 () => getLimits().catch(() => null),
25 );23 );
26- const [slug, setSlug] = createSignal("");
27 const [name, setName] = createSignal("");24 const [name, setName] = createSignal("");
28 const [adminUsername, setAdminUsername] = createSignal("");25 const [adminUsername, setAdminUsername] = createSignal("");
29 const [adminPassword, setAdminPassword] = createSignal("");26 const [adminPassword, setAdminPassword] = createSignal("");
@@ -33,7 +30,6 @@ export function CreateSchoolPanel(props: { open: boolean; onOpenChange: (open: b
33 const [pending, setPending] = createSignal(false);30 const [pending, setPending] = createSignal(false);
34 31
35 const reset = () => {32 const reset = () => {
36- setSlug("");
37 setName("");33 setName("");
38 setAdminUsername("");34 setAdminUsername("");
39 setAdminPassword("");35 setAdminPassword("");
@@ -50,7 +46,6 @@ export function CreateSchoolPanel(props: { open: boolean; onOpenChange: (open: b
50 setPending(true);46 setPending(true);
51 try {47 try {
52 const school = await postSchool({48 const school = await postSchool({
53- slug: slug().trim(),
54 name: name().trim(),49 name: name().trim(),
55 admin_username: adminUsername().trim(),50 admin_username: adminUsername().trim(),
56 admin_password: adminPassword(),51 admin_password: adminPassword(),
@@ -83,11 +78,6 @@ export function CreateSchoolPanel(props: { open: boolean; onOpenChange: (open: b
83 <Alert variant="destructive">{error()}</Alert>78 <Alert variant="destructive">{error()}</Alert>
84 </Show>79 </Show>
85 <div class="grid gap-4 sm:grid-cols-2">80 <div class="grid gap-4 sm:grid-cols-2">
86- <div class="space-y-1.5">
87- <Label for="school-slug">{t("builder.slug")}</Label>
88- <Input id="school-slug" class="rounded-lg" required pattern={SLUG_PATTERN} minlength={limits()?.user.min_slug_len ?? 2} maxlength={limits()?.user.max_slug_len ?? 32} value={slug()} onInput={(e) => setSlug(e.currentTarget.value.toLowerCase())} />
89- <p class="text-xs text-text-subtle">{t("builder.slugHint")}</p>
90- </div>
91 <div class="space-y-1.5">81 <div class="space-y-1.5">
92 <Label for="school-name">{t("builder.schoolName")}</Label>82 <Label for="school-name">{t("builder.schoolName")}</Label>
93 <Input id="school-name" class="rounded-lg" required maxlength={limits()?.user.max_school_name_len ?? 120} value={name()} onInput={(e) => setName(e.currentTarget.value)} />83 <Input id="school-name" class="rounded-lg" required maxlength={limits()?.user.max_school_name_len ?? 120} value={name()} onInput={(e) => setName(e.currentTarget.value)} />
src/components/builder/school-admin-access-panel.tsxmodified+3 -3
@@ -16,7 +16,7 @@ export type AdminAccessMode = "enter" | "password";
16 * re-keys the admin and revokes every session it held.16 * re-keys the admin and revokes every session it held.
17 */17 */
18 export function SchoolAdminAccessPanel(props: {18 export function SchoolAdminAccessPanel(props: {
19- slug: string;19+ id: string;
20 mode: AdminAccessMode | null;20 mode: AdminAccessMode | null;
21 onClose: () => void;21 onClose: () => void;
22 onEntered: () => void;22 onEntered: () => void;
@@ -40,11 +40,11 @@ export function SchoolAdminAccessPanel(props: {
40 setPending(true);40 setPending(true);
41 try {41 try {
42 if (props.mode === "enter") {42 if (props.mode === "enter") {
43- await postSchoolEnter(props.slug, { username: username().trim() });43+ await postSchoolEnter(props.id, { username: username().trim() });
44 reset();44 reset();
45 props.onEntered();45 props.onEntered();
46 } else {46 } else {
47- await postSchoolAdminPassword(props.slug, { username: username().trim(), password: password() });47+ await postSchoolAdminPassword(props.id, { username: username().trim(), password: password() });
48 reset();48 reset();
49 props.onPasswordReset();49 props.onPasswordReset();
50 }50 }
src/i18n/locales/en.tsmodified+1 -4
@@ -524,8 +524,6 @@ export const en: Dict = {
524 "builder.statusSuspended": "Suspended",524 "builder.statusSuspended": "Suspended",
525 "builder.createSchool": "New school",525 "builder.createSchool": "New school",
526 "builder.createSchoolHint": "Creates the school's database and its first admin in one step.",526 "builder.createSchoolHint": "Creates the school's database and its first admin in one step.",
527- "builder.slug": "School code",
528- "builder.slugHint": "Lowercase letters, digits and hyphens. Cannot be changed later.",
529 "builder.schoolName": "School name",527 "builder.schoolName": "School name",
530 "builder.adminUsername": "Admin username",528 "builder.adminUsername": "Admin username",
531 "builder.adminPassword": "Admin password",529 "builder.adminPassword": "Admin password",
@@ -784,7 +782,7 @@ export const en: Dict = {
784 "auth.register": "Create account",782 "auth.register": "Create account",
785 "auth.username": "Username",783 "auth.username": "Username",
786 "auth.school": "School",784 "auth.school": "School",
787- "auth.schoolHint": "{min}–{max} characters",785+ "auth.noSchoolOpen": "No school is open for registration.",
788 "auth.password": "Password",786 "auth.password": "Password",
789 "auth.noAccount": "New here?",787 "auth.noAccount": "New here?",
790 "auth.hasAccount": "Already registered?",788 "auth.hasAccount": "Already registered?",
@@ -803,7 +801,6 @@ export const en: Dict = {
803 "auth.hidePassword": "Hide password",801 "auth.hidePassword": "Hide password",
804 "auth.showConfirmPassword": "Show password confirmation",802 "auth.showConfirmPassword": "Show password confirmation",
805 "auth.hideConfirmPassword": "Hide password confirmation",803 "auth.hideConfirmPassword": "Hide password confirmation",
806- "auth.schoolCodeHint": "The school code your school gave you (not the school's name): lowercase letters, digits and hyphens, {min}–{max} characters.",
807 "auth.passwordMinHint": "At least {min} characters.",804 "auth.passwordMinHint": "At least {min} characters.",
808 "auth.passwordTooShort": "The password needs at least {min} characters.",805 "auth.passwordTooShort": "The password needs at least {min} characters.",
809 "auth.welcomeBack": "Good to see you again",806 "auth.welcomeBack": "Good to see you again",
src/i18n/locales/tr.tsmodified+1 -4
@@ -520,8 +520,6 @@ export const tr: Dict = {
520 "builder.statusSuspended": "Askıda",520 "builder.statusSuspended": "Askıda",
521 "builder.createSchool": "Yeni okul",521 "builder.createSchool": "Yeni okul",
522 "builder.createSchoolHint": "Okulun veritabanını ve ilk yöneticisini tek adımda oluşturur.",522 "builder.createSchoolHint": "Okulun veritabanını ve ilk yöneticisini tek adımda oluşturur.",
523- "builder.slug": "Okul kodu",
524- "builder.slugHint": "Küçük harf, rakam ve tire. Sonradan değiştirilemez.",
525 "builder.schoolName": "Okul adı",523 "builder.schoolName": "Okul adı",
526 "builder.adminUsername": "Yönetici kullanıcı adı",524 "builder.adminUsername": "Yönetici kullanıcı adı",
527 "builder.adminPassword": "Yönetici şifresi",525 "builder.adminPassword": "Yönetici şifresi",
@@ -780,7 +778,7 @@ export const tr: Dict = {
780 "auth.register": "Hesap oluştur",778 "auth.register": "Hesap oluştur",
781 "auth.username": "Kullanıcı adı",779 "auth.username": "Kullanıcı adı",
782 "auth.school": "Okul",780 "auth.school": "Okul",
783- "auth.schoolHint": "{min}–{max} karakter",781+ "auth.noSchoolOpen": "Kayıta açık bir okul yok.",
784 "auth.password": "Şifre",782 "auth.password": "Şifre",
785 "auth.noAccount": "Yeni misin?",783 "auth.noAccount": "Yeni misin?",
786 "auth.hasAccount": "Zaten kayıtlı mısın?",784 "auth.hasAccount": "Zaten kayıtlı mısın?",
@@ -799,7 +797,6 @@ export const tr: Dict = {
799 "auth.hidePassword": "Şifreyi gizle",797 "auth.hidePassword": "Şifreyi gizle",
800 "auth.showConfirmPassword": "Şifre onayını göster",798 "auth.showConfirmPassword": "Şifre onayını göster",
801 "auth.hideConfirmPassword": "Şifre onayını gizle",799 "auth.hideConfirmPassword": "Şifre onayını gizle",
802- "auth.schoolCodeHint": "Okulunun sana ilettiği okul kodu (okul adı değil): küçük harf, rakam ve tire, {min}–{max} karakter.",
803 "auth.passwordMinHint": "En az {min} karakter.",800 "auth.passwordMinHint": "En az {min} karakter.",
804 "auth.passwordTooShort": "Şifre en az {min} karakter olmalı.",801 "auth.passwordTooShort": "Şifre en az {min} karakter olmalı.",
805 "auth.welcomeBack": "Seni yeniden görmek güzel",802 "auth.welcomeBack": "Seni yeniden görmek güzel",
src/i18n/messages.tsmodified+1 -4
@@ -487,8 +487,6 @@ export type MessageKey =
487 | "builder.statusSuspended"487 | "builder.statusSuspended"
488 | "builder.createSchool"488 | "builder.createSchool"
489 | "builder.createSchoolHint"489 | "builder.createSchoolHint"
490- | "builder.slug"
491- | "builder.slugHint"
492 | "builder.schoolName"490 | "builder.schoolName"
493 | "builder.adminUsername"491 | "builder.adminUsername"
494 | "builder.adminPassword"492 | "builder.adminPassword"
@@ -771,7 +769,7 @@ export type MessageKey =
771 | "auth.register"769 | "auth.register"
772 | "auth.username"770 | "auth.username"
773 | "auth.school"771 | "auth.school"
774- | "auth.schoolHint"772+ | "auth.noSchoolOpen"
775 | "auth.password"773 | "auth.password"
776 | "auth.noAccount"774 | "auth.noAccount"
777 | "auth.hasAccount"775 | "auth.hasAccount"
@@ -790,7 +788,6 @@ export type MessageKey =
790 | "auth.hidePassword"788 | "auth.hidePassword"
791 | "auth.showConfirmPassword"789 | "auth.showConfirmPassword"
792 | "auth.hideConfirmPassword"790 | "auth.hideConfirmPassword"
793- | "auth.schoolCodeHint"
794 | "auth.passwordMinHint"791 | "auth.passwordMinHint"
795 | "auth.passwordTooShort"792 | "auth.passwordTooShort"
796 | "auth.welcomeBack"793 | "auth.welcomeBack"
src/lib/dev-auto-login.tsmodified+2 -2
@@ -6,7 +6,7 @@ const SKIP_KEY = "hezarfen:dev-auto-login-off";
6 /**6 /**
7 * Development-only sign-in with credentials from `.env.local`7 * Development-only sign-in with credentials from `.env.local`
8 * (`VITE_DEV_AUTOLOGIN_USERNAME`, `VITE_DEV_AUTOLOGIN_PASSWORD`, optional8 * (`VITE_DEV_AUTOLOGIN_USERNAME`, `VITE_DEV_AUTOLOGIN_PASSWORD`, optional
9- * `VITE_DEV_AUTOLOGIN_SCHOOL`). `import.meta.env.DEV` is a build-time false in9+ * `VITE_DEV_AUTOLOGIN_SCHOOL`, a school uuid). `import.meta.env.DEV` is a build-time false in
10 * `vite build`, so the whole body is dropped from production bundles.10 * `vite build`, so the whole body is dropped from production bundles.
11 * An explicit logout turns it off for the rest of the tab.11 * An explicit logout turns it off for the rest of the tab.
12 */12 */
@@ -18,7 +18,7 @@ export async function devAutoLogin(): Promise<User | null> {
18 try {18 try {
19 const result = await postLogin({ username, password });19 const result = await postLogin({ username, password });
20 if (!("schools" in result)) return result;20 if (!("schools" in result)) return result;
21- const school = import.meta.env.VITE_DEV_AUTOLOGIN_SCHOOL || result.schools[0]?.slug;21+ const school = import.meta.env.VITE_DEV_AUTOLOGIN_SCHOOL || result.schools[0]?.id;
22 return school ? await postSelectSchool({ school }) : null;22 return school ? await postSelectSchool({ school }) : null;
23 } catch (err) {23 } catch (err) {
24 console.warn("Dev auto-login failed:", err);24 console.warn("Dev auto-login failed:", err);
src/pages/builder-school-detail-page.tsxmodified+14 -14
@@ -3,11 +3,11 @@ import { createResource } from "@/lib/create-resource";
3 import { useNavigate, useParams } from "@tanstack/solid-router";3 import { useNavigate, useParams } from "@tanstack/solid-router";
4 import { getModulesCatalog } from "@/api/modules";4 import { getModulesCatalog } from "@/api/modules";
5 import {5 import {
6- deleteSchoolBySlug,6+ deleteSchool,
7 deleteSchoolModule,7 deleteSchoolModule,
8- getSchoolBySlug,8+ getSchool,
9 getSchoolModules,9 getSchoolModules,
10- patchSchoolBySlug,10+ patchSchool,
11 patchSchoolModules,11 patchSchoolModules,
12 postSchoolModule,12 postSchoolModule,
13 } from "@/api/schools";13 } from "@/api/schools";
@@ -51,12 +51,12 @@ function BuilderSchoolDetailContent() {
51 const { locale } = usePreferences();51 const { locale } = usePreferences();
52 const auth = useAuth();52 const auth = useAuth();
53 const navigate = useNavigate();53 const navigate = useNavigate();
54- const params = useParams({ from: "/builder/schools/$slug" });54+ const params = useParams({ from: "/builder/schools/$id" });
55- const slug = () => params().slug;55+ const id = () => params().id;
56 56
57- const [school, { refetch: refetchSchool }] = createResource(slug, (value) => getSchoolBySlug(value));57+ const [school, { refetch: refetchSchool }] = createResource(id, (value) => getSchool(value));
58 const [catalog] = createResource(() => getModulesCatalog());58 const [catalog] = createResource(() => getModulesCatalog());
59- const [modules] = createResource(slug, (value) => getSchoolModules(value));59+ const [modules] = createResource(id, (value) => getSchoolModules(value));
60 60
61 // The switchboard owns a local copy: each switch is one write whose response61 // The switchboard owns a local copy: each switch is one write whose response
62 // is the school's whole new set, so there is nothing to refetch.62 // is the school's whole new set, so there is nothing to refetch.
@@ -105,7 +105,7 @@ function BuilderSchoolDetailContent() {
105 event.preventDefault();105 event.preventDefault();
106 setEditError("");106 setEditError("");
107 try {107 try {
108- await patchSchoolBySlug(slug(), { name: name().trim(), status: status() });108+ await patchSchool(id(), { name: name().trim(), status: status() });
109 setEditOpen(false);109 setEditOpen(false);
110 await refetchSchool();110 await refetchSchool();
111 setFlash(t("common.saved"));111 setFlash(t("common.saved"));
@@ -127,7 +127,7 @@ function BuilderSchoolDetailContent() {
127 <PageHeader127 <PageHeader
128 eyebrow={t("builder.schools")}128 eyebrow={t("builder.schools")}
129 title={current().name}129 title={current().name}
130- description={`${current().slug} · ${t("builder.createdAt")}: ${formatDateTime(current().created_at, locale())}`}130+ description={`${current().id} · ${t("builder.createdAt")}: ${formatDateTime(current().created_at, locale())}`}
131 actions={131 actions={
132 <div class="flex flex-wrap items-center gap-2">132 <div class="flex flex-wrap items-center gap-2">
133 <SchoolStatusBadge status={current().status} />133 <SchoolStatusBadge status={current().status} />
@@ -180,10 +180,10 @@ function BuilderSchoolDetailContent() {
180 enabled={enabled()}180 enabled={enabled()}
181 disabled={modulesSaving()}181 disabled={modulesSaving()}
182 onToggle={(module, next) =>182 onToggle={(module, next) =>
183- void writeModules(() => (next ? postSchoolModule(slug(), module) : deleteSchoolModule(slug(), module)))183+ void writeModules(() => (next ? postSchoolModule(id(), module) : deleteSchoolModule(id(), module)))
184 }184 }
185 onTogglePackage={(pkg, next) =>185 onTogglePackage={(pkg, next) =>
186- void writeModules(() => patchSchoolModules(slug(), next ? { enable_packages: [pkg] } : { disable_packages: [pkg] }))186+ void writeModules(() => patchSchoolModules(id(), next ? { enable_packages: [pkg] } : { disable_packages: [pkg] }))
187 }187 }
188 />188 />
189 )}189 )}
@@ -223,7 +223,7 @@ function BuilderSchoolDetailContent() {
223 </SidePanel>223 </SidePanel>
224 224
225 <SchoolAdminAccessPanel225 <SchoolAdminAccessPanel
226- slug={slug()}226+ id={id()}
227 mode={accessMode()}227 mode={accessMode()}
228 onClose={() => setAccessMode(null)}228 onClose={() => setAccessMode(null)}
229 onPasswordReset={() => {229 onPasswordReset={() => {
@@ -244,10 +244,10 @@ function BuilderSchoolDetailContent() {
244 title={t("builder.deleteSchool")}244 title={t("builder.deleteSchool")}
245 description={t("builder.deleteSchoolWarning")}245 description={t("builder.deleteSchoolWarning")}
246 variant="destructive"246 variant="destructive"
247- summary={school() ? `${school()!.name} · ${school()!.slug}` : ""}247+ summary={school() ? `${school()!.name} · ${school()!.id}` : ""}
248 onConfirm={async () => {248 onConfirm={async () => {
249 try {249 try {
250- await deleteSchoolBySlug(slug());250+ await deleteSchool(id());
251 void navigate({ to: "/builder" });251 void navigate({ to: "/builder" });
252 } catch (err) {252 } catch (err) {
253 setError(formatApiError(err));253 setError(formatApiError(err));
src/pages/builder-schools-page.tsxmodified+13 -11
@@ -2,7 +2,7 @@ import { Show, Suspense, createMemo, createSignal } from "solid-js";
2 import { createResource } from "@/lib/create-resource";2 import { createResource } from "@/lib/create-resource";
3 import { useNavigate } from "@tanstack/solid-router";3 import { useNavigate } from "@tanstack/solid-router";
4 import type { ColumnDef } from "@tanstack/solid-table";4 import type { ColumnDef } from "@tanstack/solid-table";
5-import { deleteSchoolBySlug, getSchools, patchSchoolBySlug } from "@/api/schools";5+import { deleteSchool, getSchools, patchSchool } from "@/api/schools";
6 import { formatApiError, type School } from "@/api/client";6 import { formatApiError, type School } from "@/api/client";
7 import { BuilderGuard } from "@/components/builder/builder-guard";7 import { BuilderGuard } from "@/components/builder/builder-guard";
8 import { BuilderHeader } from "@/components/builder/builder-header";8 import { BuilderHeader } from "@/components/builder/builder-header";
@@ -42,12 +42,12 @@ function BuilderSchoolsContent() {
42 const [error, setError] = createSignal("");42 const [error, setError] = createSignal("");
43 const [flash, setFlash] = createFlash();43 const [flash, setFlash] = createFlash();
44 44
45- const open = (school: School) => void navigate({ to: "/builder/schools/$slug", params: { slug: school.slug } });45+ const open = (school: School) => void navigate({ to: "/builder/schools/$id", params: { id: school.id } });
46 46
47 const setStatus = async (school: School, status: School["status"]) => {47 const setStatus = async (school: School, status: School["status"]) => {
48 setError("");48 setError("");
49 try {49 try {
50- await patchSchoolBySlug(school.slug, { status });50+ await patchSchool(school.id, { status });
51 await refetch();51 await refetch();
52 setFlash(t("common.saved"));52 setFlash(t("common.saved"));
53 } catch (err) {53 } catch (err) {
@@ -59,12 +59,14 @@ function BuilderSchoolsContent() {
59 {59 {
60 accessorKey: "name",60 accessorKey: "name",
61 header: t("builder.schoolName"),61 header: t("builder.schoolName"),
62- cell: (cell) => <span class="font-medium">{cell.row.original.name}</span>,62+ cell: (cell) => (
63- },63+ <span class="block min-w-0">
64- {64+ <span class="block font-medium">{cell.row.original.name}</span>
65- accessorKey: "slug",65+ <span class="block truncate font-mono text-xs text-text-subtle" title={cell.row.original.id}>
66- header: t("builder.slug"),66+ {cell.row.original.id.slice(0, 8)}
67- cell: (cell) => <span class="mono text-sm">{cell.row.original.slug}</span>,67+ </span>
68+ </span>
69+ ),
68 },70 },
69 {71 {
70 accessorKey: "status",72 accessorKey: "status",
@@ -157,12 +159,12 @@ function BuilderSchoolsContent() {
157 title={t("builder.deleteSchool")}159 title={t("builder.deleteSchool")}
158 description={t("builder.deleteSchoolWarning")}160 description={t("builder.deleteSchoolWarning")}
159 variant="destructive"161 variant="destructive"
160- summary={deleteTarget() ? `${deleteTarget()!.name} · ${deleteTarget()!.slug}` : ""}162+ summary={deleteTarget() ? `${deleteTarget()!.name} · ${deleteTarget()!.id}` : ""}
161 onConfirm={async () => {163 onConfirm={async () => {
162 const school = deleteTarget();164 const school = deleteTarget();
163 if (!school) return;165 if (!school) return;
164 try {166 try {
165- await deleteSchoolBySlug(school.slug);167+ await deleteSchool(school.id);
166 await refetch();168 await refetch();
167 setFlash(t("common.deleted"));169 setFlash(t("common.deleted"));
168 } catch (err) {170 } catch (err) {
src/pages/login-page.test.tsxmodified+3 -3
@@ -54,8 +54,8 @@ test("logs in without a school and completes the multi-school selection", async
54 postLogin.mockResolvedValue({54 postLogin.mockResolvedValue({
55 username: "ada",55 username: "ada",
56 schools: [56 schools: [
57- { slug: "alpha", name: "Alpha School" },57+ { id: "019732e3-7b00-7000-8000-00000000dead", name: "Alpha School" },
58- { slug: "beta", name: "Beta School" },58+ { id: "019732e3-7b00-7000-8000-00000000beef", name: "Beta School" },
59 ],59 ],
60 });60 });
61 postSelectSchool.mockResolvedValue({ id: "u1", username: "ada", role: "student" });61 postSelectSchool.mockResolvedValue({ id: "u1", username: "ada", role: "student" });
@@ -74,7 +74,7 @@ test("logs in without a school and completes the multi-school selection", async
74 fireEvent.click(screen.getByText("Alpha School").closest("button")!);74 fireEvent.click(screen.getByText("Alpha School").closest("button")!);
75 75
76 await waitFor(() => {76 await waitFor(() => {
77- expect(postSelectSchool).toHaveBeenCalledWith({ school: "alpha" });77+ expect(postSelectSchool).toHaveBeenCalledWith({ school: "019732e3-7b00-7000-8000-00000000dead" });
78 expect(refresh).toHaveBeenCalledOnce();78 expect(refresh).toHaveBeenCalledOnce();
79 expect(navigate).toHaveBeenCalledWith({ to: "/" });79 expect(navigate).toHaveBeenCalledWith({ to: "/" });
80 });80 });
src/pages/login-page.tsxmodified+3 -3
@@ -205,14 +205,14 @@ function LoginForm() {
205 variant="outline"205 variant="outline"
206 class="h-auto w-full justify-start px-4 py-3 text-left"206 class="h-auto w-full justify-start px-4 py-3 text-left"
207 disabled={pending()}207 disabled={pending()}
208- onClick={() => void handleSchoolSelect(school.slug)}208+ onClick={() => void handleSchoolSelect(school.id)}
209 >209 >
210 <IconSchool class="h-5 w-5 shrink-0 text-primary-text" />210 <IconSchool class="h-5 w-5 shrink-0 text-primary-text" />
211 <span class="min-w-0 flex-1">211 <span class="min-w-0 flex-1">
212 <span class="block truncate font-semibold text-text-strong">{school.name}</span>212 <span class="block truncate font-semibold text-text-strong">{school.name}</span>
213- <span class="block truncate text-xs font-normal text-text-subtle">{school.slug}</span>213+ <span class="block truncate text-xs font-normal text-text-subtle">{school.id}</span>
214 </span>214 </span>
215- <Show when={selectingSchool() === school.slug}>215+ <Show when={selectingSchool() === school.id}>
216 <span class="text-xs font-normal text-text-subtle">{t("common.loading")}</span>216 <span class="text-xs font-normal text-text-subtle">{t("common.loading")}</span>
217 </Show>217 </Show>
218 </Button>218 </Button>
src/pages/register-page.tsxmodified+20 -23
@@ -1,13 +1,14 @@
1 import { Link, useNavigate } from "@tanstack/solid-router";1 import { Link, useNavigate } from "@tanstack/solid-router";
2-import { createSignal, Show } from "solid-js";2+import { For, Show, createSignal } from "solid-js";
3 import { createResource } from "@/lib/create-resource";3 import { createResource } from "@/lib/create-resource";
4-import { postRegister } from "@/api/auth";4+import { getRegisterSchools, postRegister } from "@/api/auth";
5 import { getLimits } from "@/api/limits";5 import { getLimits } from "@/api/limits";
6 import { formatApiError } from "@/api/client";6 import { formatApiError } from "@/api/client";
7 import { AuthPageShell } from "@/components/auth/auth-page-shell";7 import { AuthPageShell } from "@/components/auth/auth-page-shell";
8 import { Button } from "@/components/ui/button";8 import { Button } from "@/components/ui/button";
9 import { Input } from "@/components/ui/input";9 import { Input } from "@/components/ui/input";
10 import { Label } from "@/components/ui/label";10 import { Label } from "@/components/ui/label";
11+import { Select } from "@/components/ui/select";
11 import { GuestGuard } from "@/components/layout/guest-guard";12 import { GuestGuard } from "@/components/layout/guest-guard";
12 import { IconEye, IconEyeOff } from "@/components/ui/icons";13 import { IconEye, IconEyeOff } from "@/components/ui/icons";
13 import { useT } from "@/stores/preferences-context";14 import { useT } from "@/stores/preferences-context";
@@ -34,8 +35,8 @@ function RegisterForm() {
34 const [error, setError] = createSignal("");35 const [error, setError] = createSignal("");
35 const [pending, setPending] = createSignal(false);36 const [pending, setPending] = createSignal(false);
36 const [limits] = createResource(() => getLimits().catch(() => null));37 const [limits] = createResource(() => getLimits().catch(() => null));
37- const minSchoolSlugLength = () => limits()?.user.min_slug_len ?? 2;38+ const [schools] = createResource(() => getRegisterSchools());
38- const maxSchoolSlugLength = () => limits()?.user.max_slug_len ?? 32;39+ const noSchoolOpen = () => schools.state === "ready" && !schools.error && (schools() ?? []).length === 0;
39 const minPasswordLength = () => limits()?.user.min_password_len ?? 6;40 const minPasswordLength = () => limits()?.user.min_password_len ?? 6;
40 // Inline checks wait until the reader has left the field (or, for the41 // Inline checks wait until the reader has left the field (or, for the
41 // confirmation, typed as many characters as the password) so they never42 // confirmation, typed as many characters as the password) so they never
@@ -53,13 +54,10 @@ function RegisterForm() {
53 const handleSubmit = async (e: SubmitEvent) => {54 const handleSubmit = async (e: SubmitEvent) => {
54 e.preventDefault();55 e.preventDefault();
55 const s = school().trim();56 const s = school().trim();
57+ if (!s) return;
56 const u = username().trim();58 const u = username().trim();
57 const p = password();59 const p = password();
58 const cp = confirmPassword();60 const cp = confirmPassword();
59- if (s.length < minSchoolSlugLength() || s.length > maxSchoolSlugLength()) {
60- setError(t("auth.schoolHint", { min: minSchoolSlugLength(), max: maxSchoolSlugLength() }));
61- return;
62- }
63 const userLimits = limits()?.user;61 const userLimits = limits()?.user;
64 if (userLimits && (u.length < userLimits.min_username_len || u.length > userLimits.max_username_len)) {62 if (userLimits && (u.length < userLimits.min_username_len || u.length > userLimits.max_username_len)) {
65 setError(t("auth.usernameHint"));63 setError(t("auth.usernameHint"));
@@ -97,24 +95,23 @@ function RegisterForm() {
97 <form class="space-y-5" onSubmit={handleSubmit}>95 <form class="space-y-5" onSubmit={handleSubmit}>
98 <div class="space-y-2">96 <div class="space-y-2">
99 <Label for="register-school">{t("auth.school")}</Label>97 <Label for="register-school">{t("auth.school")}</Label>
100- <Input98+ <Select
101 id="register-school"99 id="register-school"
102 class="h-9"100 class="h-9"
103- autocapitalize="none"
104- autocomplete="off"
105- spellcheck={false}
106- minlength={minSchoolSlugLength()}
107- maxlength={maxSchoolSlugLength()}
108 required101 required
109- aria-describedby="register-school-hint"102+ disabled={schools.loading || noSchoolOpen() || Boolean(schools.error)}
110 value={school()}103 value={school()}
111- // A school code (slug) is lowercase; folding here saves a104+ onChange={(e) => setSchool(e.currentTarget.value)}
112- // round trip for "Ata-Koleji".105+ >
113- onInput={(e) => setSchool(e.currentTarget.value.toLowerCase())}106+ <option value="">{t("auth.chooseSchoolTitle")}</option>
114- />107+ <For each={schools() ?? []}>{(item) => <option value={item.id}>{item.name}</option>}</For>
115- <p id="register-school-hint" class="text-xs text-text-subtle">108+ </Select>
116- {t("auth.schoolCodeHint", { min: minSchoolSlugLength(), max: maxSchoolSlugLength() })}109+ <Show when={noSchoolOpen()}>
117- </p>110+ <p class="text-sm text-text-subtle">{t("auth.noSchoolOpen")}</p>
111+ </Show>
112+ <Show when={schools.error}>
113+ <p class="text-sm text-destructive-text">{formatApiError(schools.error)}</p>
114+ </Show>
118 </div>115 </div>
119 116
120 <div class="space-y-2">117 <div class="space-y-2">
@@ -206,7 +203,7 @@ function RegisterForm() {
206 <p class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive-text">{error()}</p>203 <p class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive-text">{error()}</p>
207 )}204 )}
208 205
209- <Button type="submit" class="h-9 w-full text-sm" disabled={pending()}>206+ <Button type="submit" class="h-9 w-full text-sm" disabled={pending() || schools.loading || noSchoolOpen() || Boolean(schools.error) || !school()}>
210 {pending() ? t("common.loading") : t("auth.register")}207 {pending() ? t("common.loading") : t("auth.register")}
211 </Button>208 </Button>
212 </form>209 </form>
src/routes/router.tsxmodified+1 -1
@@ -542,7 +542,7 @@ const builderSchoolsRoute = createRoute({
542 542
543 const builderSchoolDetailRoute = createRoute({543 const builderSchoolDetailRoute = createRoute({
544 getParentRoute: () => rootRoute,544 getParentRoute: () => rootRoute,
545- path: "/builder/schools/$slug",545+ path: "/builder/schools/$id",
546 component: BuilderSchoolDetailPage,546 component: BuilderSchoolDetailPage,
547 });547 });
548 548
src/vite-env.d.tsmodified+1 -0
@@ -4,6 +4,7 @@ interface ImportMetaEnv {
4 /** Dev-only auto sign-in (see src/lib/dev-auto-login.ts); set in .env.local, never committed. */4 /** Dev-only auto sign-in (see src/lib/dev-auto-login.ts); set in .env.local, never committed. */
5 readonly VITE_DEV_AUTOLOGIN_USERNAME?: string;5 readonly VITE_DEV_AUTOLOGIN_USERNAME?: string;
6 readonly VITE_DEV_AUTOLOGIN_PASSWORD?: string;6 readonly VITE_DEV_AUTOLOGIN_PASSWORD?: string;
7+ /** Optional school uuid when login returns a choice list. */
7 readonly VITE_DEV_AUTOLOGIN_SCHOOL?: string;8 readonly VITE_DEV_AUTOLOGIN_SCHOOL?: string;
8 /** Demo account prefilled on the login page (see src/lib/demo-login.ts); bundled when set. */9 /** Demo account prefilled on the login page (see src/lib/demo-login.ts); bundled when set. */
9 readonly VITE_DEMO_LOGIN_USERNAME?: string;10 readonly VITE_DEMO_LOGIN_USERNAME?: string;