Orgs: let any user create an organization and become its admin
Organization writes were superadmin-only, so standing up a tenant needed an out-of-band superadmin. Creating one is now self-service, and an admin manages the org they belong to. - POST /api/orgs is open to any authenticated user. A creator who isn't a superadmin must have no organization yet (a single-valued membership relation means a second one would abandon the first), and is promoted to the new org's admin and first member in the same request. If that promotion fails the org is rolled back, so it is never left stranded with nobody able to administer it. Superadmins still create tenants without joining them. - PATCH/DELETE are manager-gated and scope an admin to their own org. An admin deletes theirs only as its sole member: they are detached and demoted to a plain user before the record goes, so the org is empty when it is removed. Other members still block deletion with a 409. - /api/me now carries organization + organizationName, which the clients need to tell "no org yet" from "org you administer". The panel, Web App (new OrgManager.vue in Settings) and Phone App (new _OrganizationSection) all mirror the server's gates rather than re-deciding them. The Phone App cached its role at login and gates the Users tab on it, so AuthService.adoptRole refreshes that from the profile instead of making a freshly promoted admin sign in again. Covered by orgs_test.go, which drives the real handler + middleware chain against a stand-in PocketBase: promotion, the already-a-member refusal, superadmin staying unattached, the rollback, own-org scoping, the detach-and-demote, and the blocking-member 409. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
358ee68f94
commit
cd16d4383f
@@ -73,11 +73,15 @@
|
||||
"orgs": {
|
||||
"title": "Organisationer",
|
||||
"subtitle": "Enheder, som brugere tilhører",
|
||||
"subtitleOwn": "Din organisation",
|
||||
"subtitleNone": "Opret en for at administrere dit eget team",
|
||||
"newOrg": "Ny organisation",
|
||||
"namePlaceholder": "Acme Fleet",
|
||||
"empty": "Ingen organisationer endnu.",
|
||||
"createHint": "Du har endnu ingen organisation. Opret en for at blive dens administrator.",
|
||||
"colId": "ID",
|
||||
"confirmDelete": "Slet organisationen \"{name}\"?"
|
||||
"confirmDelete": "Slet organisationen \"{name}\"?",
|
||||
"confirmDeleteOwn": "Slet din organisation „{name}“? Du fjernes fra den og bliver en almindelig bruger."
|
||||
},
|
||||
|
||||
"pocketbase": {
|
||||
|
||||
@@ -73,11 +73,15 @@
|
||||
"orgs": {
|
||||
"title": "Organizations",
|
||||
"subtitle": "Tenants users belong to",
|
||||
"subtitleOwn": "Your organization",
|
||||
"subtitleNone": "Create one to manage your own team",
|
||||
"newOrg": "New organization",
|
||||
"namePlaceholder": "Acme Fleet",
|
||||
"empty": "No organizations yet.",
|
||||
"createHint": "You have no organization yet. Create one to become its admin.",
|
||||
"colId": "ID",
|
||||
"confirmDelete": "Delete the organization \"{name}\"?"
|
||||
"confirmDelete": "Delete the organization \"{name}\"?",
|
||||
"confirmDeleteOwn": "Delete your organization \"{name}\"? You will be removed from it and become a regular user."
|
||||
},
|
||||
|
||||
"pocketbase": {
|
||||
|
||||
@@ -73,11 +73,15 @@
|
||||
"orgs": {
|
||||
"title": "Organizacje",
|
||||
"subtitle": "Podmioty, do których należą użytkownicy",
|
||||
"subtitleOwn": "Twoja organizacja",
|
||||
"subtitleNone": "Utwórz ją, aby zarządzać własnym zespołem",
|
||||
"newOrg": "Nowa organizacja",
|
||||
"namePlaceholder": "Acme Fleet",
|
||||
"empty": "Brak organizacji.",
|
||||
"createHint": "Nie masz jeszcze organizacji. Utwórz ją, aby zostać jej administratorem.",
|
||||
"colId": "ID",
|
||||
"confirmDelete": "Usunąć organizację „{name}”?"
|
||||
"confirmDelete": "Usunąć organizację „{name}”?",
|
||||
"confirmDeleteOwn": "Usunąć Twoją organizację „{name}”? Zostaniesz z niej usunięty i staniesz się zwykłym użytkownikiem."
|
||||
},
|
||||
|
||||
"pocketbase": {
|
||||
|
||||
Reference in New Issue
Block a user