Skip to content

Conversation

@Abhishek-Punhani
Copy link

@Abhishek-Punhani Abhishek-Punhani commented Dec 30, 2025

Description

This PR fixes a critical bug where the application would freeze or enter an infinite redirect loop when a user clicked "Sign Out".

Related Issue

Fixes #2305

Changes Made

  • Updated useAuth.ts to explicitly remove the refreshToken along with jwtToken

Checklist

Please ensure the following before submitting your PR:

  • I have reviewed the project's contribution guidelines.
  • I have written unit tests for the changes (if applicable).
  • I have updated the documentation (if applicable).
  • I have tested the changes locally and ensured they work as expected.
  • My code follows the project's coding standards.

Screenshots or Logs (if applicable)

2025-12-30.23-17-12.mp4

Additional Notes

Copilot AI review requested due to automatic review settings December 30, 2025 17:44
@kubestellar-prow
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kunal-511 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow
Copy link

Hi @Abhishek-Punhani. Thanks for your PR.

I'm waiting for a kubestellar member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a critical bug where the logout functionality was causing the application to freeze or enter an infinite redirect loop. The root cause was that only the jwtToken was being removed during logout, while the refreshToken remained in localStorage, potentially causing authentication conflicts.

  • Added localStorage.removeItem('refreshToken') to both logout implementations in useAuth.ts
  • Ensures complete cleanup of authentication tokens during sign out

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 36 to +37
localStorage.removeItem('jwtToken');
localStorage.removeItem('refreshToken');
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a clearTokens() utility function already available in frontend/src/components/login/tokenUtils.ts that handles removing both jwtToken and refreshToken. Consider using that function instead of manually removing tokens to maintain consistency with other logout implementations in the codebase (e.g., the logout function in useLogin.ts already uses clearTokens()).

Copilot uses AI. Check for mistakes.
Comment on lines 48 to +49
localStorage.removeItem('jwtToken');
localStorage.removeItem('refreshToken');
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a clearTokens() utility function already available in frontend/src/components/login/tokenUtils.ts that handles removing both jwtToken and refreshToken. Consider using that function instead of manually removing tokens to maintain consistency with other logout implementations in the codebase (e.g., the logout function in useLogin.ts already uses clearTokens()).

Copilot uses AI. Check for mistakes.
Comment on lines 35 to 40
logout: () => {
localStorage.removeItem('jwtToken');
localStorage.removeItem('refreshToken');
localStorage.setItem('tokenRemovalTime', Date.now().toString());
queryClient.invalidateQueries({ queryKey: AUTH_QUERY_KEY });
},
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logout functions lack test coverage. Consider adding unit tests to verify that both jwtToken and refreshToken are properly removed during logout, especially given this is fixing a critical bug. Tests would help prevent regression of this issue.

Copilot uses AI. Check for mistakes.
@onkar717
Copy link
Contributor

onkar717 commented Jan 1, 2026

/ok-to-test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

[Bug]: App Freezes/Infinite Loop on Logout

2 participants