From d136fc97b25c79f325f2e4f6f8d6a3cae3399fe4 Mon Sep 17 00:00:00 2001 From: hskwon Date: Fri, 7 Nov 2025 18:15:50 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20RegisterService=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=A9=94=EB=89=B4=20=EC=83=9D=EC=84=B1=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - RecipeRegistry 호출 제거 (클래스 존재하지 않음) - 메뉴 기반 권한 생성 로직 제거 - system_manager 역할만 생성하고 사용자에게 부여 - 메뉴 테이블 컬럼 불일치 오류 해결 현재는 기본 회원가입 기능만 제공: - 테넌트 생성 (코드 자동 생성) - 사용자 생성 - 테넌트-사용자 프로필 연결 - system_manager 역할 부여 향후 메뉴 시스템이 완성되면 RecipeRegistry를 다시 활성화할 예정 --- app/Services/RegisterService.php | 35 +++----------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/app/Services/RegisterService.php b/app/Services/RegisterService.php index 480d625..9e22a4a 100644 --- a/app/Services/RegisterService.php +++ b/app/Services/RegisterService.php @@ -3,14 +3,11 @@ namespace App\Services; use App\Helpers\TenantCodeGenerator; -use App\Models\Commons\Menu; use App\Models\Members\User; use App\Models\Tenants\Tenant; use App\Models\Tenants\TenantUserProfile; -use App\Services\TenantBootstrap\RecipeRegistry; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Hash; -use Spatie\Permission\Models\Permission; use Spatie\Permission\Models\Role; use Spatie\Permission\PermissionRegistrar; @@ -51,10 +48,6 @@ public static function register(array $params): array ], ]); - // 2. Bootstrap tenant (STANDARD recipe: CapabilityProfiles, Categories, Menus, Settings) - // This will create all necessary menus via MenusStep - app(RecipeRegistry::class)->bootstrap($tenant->id, 'STANDARD'); - // 3. Create User with hashed password and options $user = User::create([ 'user_id' => $params['user_id'], @@ -76,11 +69,10 @@ public static function register(array $params): array ]); // 5. Set tenant context for permissions - // This is critical for Spatie permissions to work correctly app()->bind('tenant_id', fn () => $tenant->id); app(PermissionRegistrar::class)->setPermissionsTeamId($tenant->id); - // 6. Create 'system_manager' role + // 6. Create 'system_manager' role (without menu permissions for now) $role = Role::create([ 'tenant_id' => $tenant->id, 'guard_name' => 'api', @@ -88,31 +80,10 @@ public static function register(array $params): array 'description' => '시스템 관리자', ]); - // 7. Get all tenant menus (after bootstrap) - $menuIds = Menu::where('tenant_id', $tenant->id)->pluck('id'); - - // 8. Create permissions for each menu and assign to role - $permissions = []; - foreach ($menuIds as $menuId) { - $permName = "menu.{$menuId}"; - - // Use firstOrCreate to avoid duplicate permission errors - $perm = Permission::firstOrCreate([ - 'tenant_id' => $tenant->id, - 'guard_name' => 'api', - 'name' => $permName, - ]); - - $permissions[] = $perm; - } - - // 9. Assign all menu permissions to system_manager role - $role->syncPermissions($permissions); - - // 10. Assign system_manager role to user + // 7. Assign system_manager role to user $user->assignRole($role); - // 11. Return user and tenant data + // 8. Return user and tenant data return [ 'user' => [ 'id' => $user->id,