refactor(dev-tools): 인증 시스템 통합 및 테넌트 사용자 조회 개선
## 인증 모달 통합
- api-explorer, flow-tester, api-logs 3개 페이지의 인증 UI 통합
- 공유 컴포넌트 생성: auth-modal.blade.php, auth-scripts.blade.php
- sessionStorage 기반으로 페이지 간 인증 상태 공유
- DevToolsAuth 글로벌 JavaScript API 제공
## 테넌트 사용자 조회 개선
- 시스템 헤더에서 선택한 테넌트의 사용자 목록 표시
- 관리자가 모든 테넌트의 사용자 조회 가능 (소속 무관)
- session('selected_tenant_id')로 Tenant 모델 직접 조회
- 테넌트 미선택 시 안내 메시지 표시
## 버그 수정
- /users 페이지 HTMX swap 오류 수정 (JSON→HTML 직접 반환)
- 사용자 이름 JavaScript 이스케이프 처리 (@js() 사용)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -447,31 +447,50 @@ public function setDefaultEnvironment(int $id): JsonResponse
|
||||
|
||||
/**
|
||||
* 현재 테넌트의 사용자 목록
|
||||
* 시스템 헤더에서 선택한 테넌트 기준 (session('selected_tenant_id'))
|
||||
* 관리자는 자신이 속하지 않은 테넌트의 사용자도 볼 수 있어야 함
|
||||
*/
|
||||
public function users(): JsonResponse
|
||||
{
|
||||
// user_tenants 피벗 테이블에서 기본 테넌트 조회
|
||||
$defaultTenant = \DB::table('user_tenants')
|
||||
->where('user_id', auth()->id())
|
||||
->where('is_default', true)
|
||||
->first();
|
||||
// 세션에서 직접 테넌트 ID 조회 (관리자가 선택한 테넌트)
|
||||
$selectedTenantId = session('selected_tenant_id');
|
||||
|
||||
if (!$defaultTenant) {
|
||||
if (!$selectedTenantId) {
|
||||
// 테넌트가 선택되지 않은 경우 로그인 사용자의 기본 테넌트 사용
|
||||
$currentTenant = auth()->user()->tenants()
|
||||
->where('is_default', true)
|
||||
->first() ?? auth()->user()->tenants()->first();
|
||||
|
||||
if (!$currentTenant) {
|
||||
return response()->json([]);
|
||||
}
|
||||
|
||||
$selectedTenantId = $currentTenant->id;
|
||||
}
|
||||
|
||||
// Tenant 모델에서 직접 조회 (사용자의 테넌트 관계와 무관하게)
|
||||
$tenant = \App\Models\Tenants\Tenant::find($selectedTenantId);
|
||||
|
||||
if (!$tenant) {
|
||||
return response()->json([]);
|
||||
}
|
||||
|
||||
$tenantId = $defaultTenant->tenant_id;
|
||||
|
||||
// 해당 테넌트에 속한 사용자 목록 조회
|
||||
$users = \App\Models\User::whereHas('tenants', function ($query) use ($tenantId) {
|
||||
$query->where('tenant_id', $tenantId);
|
||||
$users = \App\Models\User::whereHas('tenants', function ($query) use ($selectedTenantId) {
|
||||
$query->where('tenant_id', $selectedTenantId);
|
||||
})
|
||||
->select(['id', 'name', 'email'])
|
||||
->orderBy('name')
|
||||
->limit(100)
|
||||
->get();
|
||||
|
||||
return response()->json($users);
|
||||
return response()->json([
|
||||
'tenant' => [
|
||||
'id' => $tenant->id,
|
||||
'name' => $tenant->company_name,
|
||||
],
|
||||
'users' => $users,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user