fix: Flow Tester 인증 및 UI 오류 수정
- FlowTesterController: users() 메서드 피벗 테이블 쿼리로 변경 - FlowExecutor: 세션 토큰 우선순위 추가 (모달 토큰 사용) - index.blade.php: tenant_id 표시 및 토큰 프리뷰 UI 수정
This commit is contained in:
@@ -346,10 +346,25 @@ public function runDetail(int $runId): View
|
||||
*/
|
||||
public function users()
|
||||
{
|
||||
$tenantId = auth()->user()->tenant_id;
|
||||
// 현재 선택된 테넌트 ID (세션 기반)
|
||||
$tenantId = session('selected_tenant_id');
|
||||
|
||||
$users = \App\Models\User::where('tenant_id', $tenantId)
|
||||
->select(['id', 'name', 'email', 'tenant_id'])
|
||||
if (! $tenantId) {
|
||||
// 세션에 없으면 기본 테넌트 사용
|
||||
$currentTenant = auth()->user()->currentTenant();
|
||||
$tenantId = $currentTenant?->id;
|
||||
}
|
||||
|
||||
if (! $tenantId) {
|
||||
return response()->json([]);
|
||||
}
|
||||
|
||||
// user_tenants 피벗 테이블을 통해 해당 테넌트의 사용자 조회
|
||||
$users = \App\Models\User::whereHas('tenants', function ($query) use ($tenantId) {
|
||||
$query->where('tenants.id', $tenantId)
|
||||
->where('user_tenants.is_active', true);
|
||||
})
|
||||
->select(['id', 'name', 'email'])
|
||||
->orderBy('name')
|
||||
->limit(100)
|
||||
->get();
|
||||
@@ -391,7 +406,6 @@ public function selectUser(Request $request)
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'email' => $user->email,
|
||||
'tenant_id' => $user->tenant_id,
|
||||
],
|
||||
'token_preview' => substr($token, 0, 20).'...',
|
||||
]);
|
||||
@@ -447,7 +461,6 @@ public function tokenStatus()
|
||||
'id' => $user->id,
|
||||
'name' => $user->name,
|
||||
'email' => $user->email,
|
||||
'tenant_id' => $user->tenant_id,
|
||||
] : null,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -403,16 +403,23 @@ private function applyConfig(array $config): void
|
||||
|
||||
/**
|
||||
* 기본 Bearer 토큰 조회
|
||||
* 우선순위: 사용자 api_token → .env FLOW_TESTER_API_TOKEN
|
||||
* 우선순위: 세션 토큰 → 사용자 api_token → .env FLOW_TESTER_API_TOKEN
|
||||
*/
|
||||
private function getDefaultBearerToken(): ?string
|
||||
{
|
||||
$user = auth()->user();
|
||||
// 1. 세션에 저장된 토큰 (API Explorer/Flow Tester 인증 모달에서 저장)
|
||||
$sessionToken = session('api_explorer_token');
|
||||
if (! empty($sessionToken)) {
|
||||
return $sessionToken;
|
||||
}
|
||||
|
||||
// 2. 로그인 사용자의 api_token
|
||||
$user = auth()->user();
|
||||
if ($user && ! empty($user->api_token)) {
|
||||
return $user->api_token;
|
||||
}
|
||||
|
||||
// 3. 환경변수 기본 토큰 (fallback)
|
||||
return env('FLOW_TESTER_API_TOKEN');
|
||||
}
|
||||
|
||||
|
||||
@@ -498,7 +498,7 @@ class="w-full border rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-blue-5
|
||||
@if($selectedUser ?? null)
|
||||
✅ {{ $selectedUser->name }} ({{ $selectedUser->email }})
|
||||
@elseif($savedToken)
|
||||
인증됨
|
||||
✅ 인증됨
|
||||
@else
|
||||
인증 필요
|
||||
@endif
|
||||
@@ -506,7 +506,12 @@ class="w-full border rounded-lg px-3 py-2 text-sm focus:ring-2 focus:ring-blue-5
|
||||
</div>
|
||||
@if($selectedUser ?? null)
|
||||
<div class="text-xs text-gray-500 mt-1">
|
||||
tenant_id: {{ $selectedUser->tenant_id }}, user_id: {{ $selectedUser->id }}
|
||||
tenant_id: {{ session('selected_tenant_id', '-') }}, user_id: {{ $selectedUser->id }}
|
||||
</div>
|
||||
@endif
|
||||
@if($savedToken)
|
||||
<div class="text-xs text-gray-500 mt-1 font-mono">
|
||||
토큰: {{ Str::limit($savedToken, 30, '...') }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@@ -802,7 +807,7 @@ function loadUsers() {
|
||||
users.forEach(user => {
|
||||
const option = document.createElement('option');
|
||||
option.value = user.id;
|
||||
option.textContent = `${user.name} (${user.email}) - tenant: ${user.tenant_id}`;
|
||||
option.textContent = `${user.name} (${user.email})`;
|
||||
select.appendChild(option);
|
||||
});
|
||||
usersLoaded = true;
|
||||
|
||||
Reference in New Issue
Block a user