fix(mng): HTMX 요청 시 JSON 에러 응답 반환 및 Role 테넌트 분리
- EnsureHQMember: HTMX/AJAX 요청 시 JSON 응답 반환 - EnsureSuperAdmin: HX-Request 헤더 체크 추가 - bootstrap/app.php: 전역 Exception Handler에서 HTMX 요청 처리 - RoleService: SpatieRole → App\Models\Role로 변경하여 테넌트별 역할 분리 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Spatie\Permission\Models\Role as SpatieRole;
|
||||
|
||||
class RoleService
|
||||
{
|
||||
@@ -55,11 +54,11 @@ public function getRoles(array $filters = [], int $perPage = 15): LengthAwarePag
|
||||
/**
|
||||
* 특정 역할 조회
|
||||
*/
|
||||
public function getRoleById(int $id): ?SpatieRole
|
||||
public function getRoleById(int $id): ?Role
|
||||
{
|
||||
$tenantId = session('selected_tenant_id');
|
||||
|
||||
$query = SpatieRole::query()->with('permissions');
|
||||
$query = Role::query()->with('permissions');
|
||||
|
||||
// Tenant 필터링 (선택된 경우에만)
|
||||
if ($tenantId && $tenantId !== 'all') {
|
||||
@@ -72,13 +71,13 @@ public function getRoleById(int $id): ?SpatieRole
|
||||
/**
|
||||
* 역할 생성
|
||||
*/
|
||||
public function createRole(array $data): SpatieRole
|
||||
public function createRole(array $data): Role
|
||||
{
|
||||
$tenantId = session('selected_tenant_id');
|
||||
$effectiveTenantId = ($tenantId && $tenantId !== 'all') ? $tenantId : null;
|
||||
$guardName = $data['guard_name'] ?? 'api';
|
||||
|
||||
$role = SpatieRole::create([
|
||||
$role = Role::create([
|
||||
'tenant_id' => $effectiveTenantId,
|
||||
'guard_name' => $guardName,
|
||||
'name' => $data['name'],
|
||||
@@ -125,7 +124,7 @@ public function updateRole(int $id, array $data): bool
|
||||
/**
|
||||
* 메뉴 권한 동기화
|
||||
*/
|
||||
protected function syncMenuPermissions(SpatieRole $role, array $menuPermissions, ?int $tenantId, string $guardName): void
|
||||
protected function syncMenuPermissions(Role $role, array $menuPermissions, ?int $tenantId, string $guardName): void
|
||||
{
|
||||
// 기존 메뉴 권한 모두 제거
|
||||
DB::table('role_has_permissions')
|
||||
@@ -195,7 +194,7 @@ public function isNameExists(string $name, ?int $excludeId = null): bool
|
||||
{
|
||||
$tenantId = session('selected_tenant_id');
|
||||
|
||||
$query = SpatieRole::where('guard_name', 'web')
|
||||
$query = Role::where('guard_name', 'web')
|
||||
->where('name', $name);
|
||||
|
||||
if ($tenantId && $tenantId !== 'all') {
|
||||
@@ -216,7 +215,7 @@ public function getActiveRoles(): Collection
|
||||
{
|
||||
$tenantId = session('selected_tenant_id');
|
||||
|
||||
$query = SpatieRole::query()->where('guard_name', 'web');
|
||||
$query = Role::query()->where('guard_name', 'web');
|
||||
|
||||
// Tenant 필터링 (선택된 경우에만)
|
||||
if ($tenantId && $tenantId !== 'all') {
|
||||
@@ -233,7 +232,7 @@ public function getRoleStats(): array
|
||||
{
|
||||
$tenantId = session('selected_tenant_id');
|
||||
|
||||
$baseQuery = SpatieRole::query()->where('guard_name', 'web');
|
||||
$baseQuery = Role::query()->where('guard_name', 'web');
|
||||
|
||||
// Tenant 필터링 (선택된 경우에만)
|
||||
if ($tenantId && $tenantId !== 'all') {
|
||||
|
||||
Reference in New Issue
Block a user