Skip to content

Add Logout logic and Remove Sample Curl in Proxy - #3081

Merged
Thushani-Jayasekera merged 1 commit into
wso2:mainfrom
Induwara04:improvement-beta
Aug 3, 2026
Merged

Add Logout logic and Remove Sample Curl in Proxy#3081
Thushani-Jayasekera merged 1 commit into
wso2:mainfrom
Induwara04:improvement-beta

Conversation

@Induwara04

Copy link
Copy Markdown
Contributor

This pull request introduces a centralized and consistent mechanism for handling unauthorized API responses (HTTP 401) throughout the application. It adds a new handleUnauthorizedResponse utility to trigger a single logout and redirect flow when a session expires, and integrates this handler into all major API layers. Additionally, it removes unused code related to LLM providers from the LLMProxyOverviewTab component.

Session Management and API Error Handling:

  • Added a new handleUnauthorizedResponse function in logout.ts that ensures only one forced logout/redirect occurs when multiple API calls return 401 due to session expiry. This prevents duplicate logout attempts and competing redirects.
  • Integrated handleUnauthorizedResponse into all major API clients and context fetchers (platformApis.ts, choreoApiClient.ts, ChoreoUserContext.tsx) so that unauthorized responses consistently trigger the session-expiry flow. [1] [2] [3] [4] [5] [6] [7]

Code Cleanup and Refactoring:

  • Removed the unused clearStoredToken call from clearAuthData in logout.ts, as it is no longer needed.
  • Cleaned up the LLMProxyOverviewTab component by removing unused imports and logic related to LLM provider templates and the ApiTryOutCurlSnippet component, simplifying the component and reducing unnecessary dependencies. [1] [2] [3] [4] [5]

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: eaa0f6f9-6282-4ee3-9bff-031428c2e99f

📥 Commits

Reviewing files that changed from the base of the PR and between 053095c and 9c5a0d4.

📒 Files selected for processing (5)
  • portals/ai-workspace/src/apis/platformApis.ts
  • portals/ai-workspace/src/auth/logout.ts
  • portals/ai-workspace/src/clients/choreoApiClient.ts
  • portals/ai-workspace/src/contexts/ChoreoUserContext.tsx
  • portals/ai-workspace/src/pages/appShell/appShellPages/proxies/LLMProxyOverviewTab.tsx
💤 Files with no reviewable changes (1)
  • portals/ai-workspace/src/pages/appShell/appShellPages/proxies/LLMProxyOverviewTab.tsx

📝 Walkthrough

Walkthrough

The AI workspace now centralizes authenticated 401 handling across platform, Choreo, and organization API requests. The logout flow prevents duplicate forced redirects. The proxy overview no longer renders the generated API-key cURL snippet.

Changes

Authentication and API error handling

Layer / File(s) Summary
Guarded unauthorized response handling
portals/ai-workspace/src/auth/logout.ts
clearAuthData no longer clears the stored API token. The new handleUnauthorizedResponse starts forced logout once for 401 responses.
API unauthorized handling integration
portals/ai-workspace/src/apis/platformApis.ts, portals/ai-workspace/src/clients/choreoApiClient.ts, portals/ai-workspace/src/contexts/ChoreoUserContext.tsx
Platform, standard, multipart, and organization API failures invoke handleUnauthorizedResponse before existing error handling.

Proxy overview cleanup

Layer / File(s) Summary
Generated cURL snippet removal
portals/ai-workspace/src/pages/appShell/appShellPages/proxies/LLMProxyOverviewTab.tsx
The overview tab no longer loads LLM providers or renders the generated API-key cURL try-out snippet.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant APIRequest
  participant handleUnauthorizedResponse
  participant forceLogoutAndRedirect
  APIRequest->>handleUnauthorizedResponse: process failed response
  handleUnauthorizedResponse->>forceLogoutAndRedirect: start once for 401
Loading

Possibly related PRs

Suggested reviewers: lasanthas, thivindu, virajsalaka

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the code changes but omits the required template sections for purpose, goals, testing, security, documentation, samples, and environment. Complete the required template sections, including purpose, goals, approach, documentation, tests, security checks, samples, related PRs, and test environment.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the two main changes: centralized logout handling and removal of the proxy sample cURL.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Thushani-Jayasekera

Copy link
Copy Markdown
Contributor

issue: #3092

@Thushani-Jayasekera
Thushani-Jayasekera merged commit a66f40f into wso2:main Aug 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants