Skip to content

[fix]: add token validation before fetching user data - #123

Closed
AnkitRewar11 wants to merge 1 commit into
layer5io:masterfrom
AnkitRewar11:fix/kanvas-login-auth
Closed

AnkitRewar11 wants to merge 1 commit into
layer5io:masterfrom
AnkitRewar11:fix/kanvas-login-auth

Conversation

@AnkitRewar11

@AnkitRewar11 AnkitRewar11 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Notes for Reviewers

This PR fixes #121

Fixed the login state in the navigation.

  • Only fetches the profile when a valid token is available.
  • Restores the user state after a successful profile request.
  • Hides the Login button for logged-in users.
  • Prevents Authorization: Bearer null requests.

Note: CORS still needs to be configured on the Cloud API side.

Signed commits

  • Yes, I signed my commits.

Summary by CodeRabbit

  • Bug Fixes
    • Improved navigation behavior for visitors without an active sign-in session.
    • User profile information now displays correctly after a successful sign-in.
    • Prevented unnecessary profile loading attempts when authentication details are unavailable.

Signed-off-by: ankitrewar11 <rewarankit18@gmail.com>
@github-actions github-actions Bot added area/ci Continuous integration | Build and release component/kanvas-docs labels Sep 21, 2026
@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: b8fd41c3-7972-4819-9aa5-1127547ea60e

📥 Commits

Reviewing files that changed from the base of the PR and between 0f048b8 and 3662d56.

📒 Files selected for processing (1)
  • src/sitecomponents/Navigation/index.js

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Navigation now skips the profile API request when provider_token is unavailable. Successful profile responses now update the userData state.

Changes

Navigation profile fetch

Layer / File(s) Summary
Profile fetch guard and state update
src/sitecomponents/Navigation/index.js
fetchData returns before calling CLOUD_USER_API when no provider token exists. Successful responses now execute setUserData(data).

Priority: ➖ Normal

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Medium

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The change satisfies issue #121. fetchData reads provider_token and returns before axios.get when no token exists. The request uses the token value, so the missing-token path does not send `Auth…
Out of Scope Changes check ✅ Passed The reviewed change is limited to authentication-state handling in src/sitecomponents/Navigation/index.js. The token guard, profile-state update, and Login visibility support issue #121. No unrelate…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: validating the authentication token before fetching user data.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

@AnkitRewar11
AnkitRewar11 deleted the fix/kanvas-login-auth branch September 21, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ci Continuous integration | Build and release component/kanvas-docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auth token missing in profile API request

1 participant