Make first user of instance automatically super_admin (#655)

* Implement dynamic role assignment for new family creators.

Introduced `User.role_for_new_family_creator` to assign `super_admin` to the first user of an instance and a configurable fallback role (e.g., `admin`) to subsequent users. Updated controllers and tests accordingly.

* Update default fallback role for family creators to admin.

---------

Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
This commit is contained in:
LPW
2026-01-16 15:27:55 -05:00
committed by GitHub
parent 0c2026680c
commit 9792ab838f
7 changed files with 61 additions and 6 deletions

View File

@@ -36,9 +36,10 @@ module Api
user = User.new(user_signup_params)
# Create family for new user
# First user of an instance becomes super_admin
family = Family.new
user.family = family
user.role = :admin
user.role = User.role_for_new_family_creator
if user.save
# Claim invite code if provided