Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove token when get Unauthorized #4193

Merged
merged 5 commits into from
Sep 27, 2023

Conversation

jamshidi799
Copy link
Contributor

@jamshidi799 jamshidi799 commented Sep 12, 2023

What problem does this PR solve?

When the token expires, the dashboard will need you to manually delete the token from the settings section and log out. This PR deletes the token automatically when a 500 response code which includes Unauthorized text happens. After that, the dashboard will redirect to /#/dashboard path and it will show the Auth dialog.

Moreover, when I try to remove the token from the settings page, I face the below error which fixed by this PR.

Screenshot 2023-09-13 at 1 55 25 AM

Close #4170

What's changed and how it works?

Related changes

  • This change also requires further updates to the website (e.g. docs)
  • This change also requires further updates to the UI interface

Cherry-pick to release branches (optional)

This PR should be cherry-picked to the following release branches:

  • release-2.6
  • release-2.5

Checklist

CHANGELOG

Must include at least one of them.

  • I have updated the CHANGELOG.md
  • I have labeled this PR with "no-need-update-changelog"

Tests

Must include at least one of them.

  • Unit test
  • E2E test
  • Manual test

Side effects

  • Breaking backward compatibility

DCO

If you find the DCO check fails, please run commands like below (Depends on the actual situations. For example, if the failed commit isn't the most recent) to fix it:

git commit --amend --signoff
git push --force

Signed-off-by: Mohammad Jamshidi <jamshidi.m799@gmail.com>
Signed-off-by: Mohammad Jamshidi <jamshidi.m799@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
@g1eny0ung
Copy link
Member

g1eny0ung commented Sep 27, 2023

Moreover, when I try to remove the token from the settings page, I face the below error which fixed by this PR.

Screenshot 2023-09-13 at 1 55 25 AM

I updated the code to fix this problem, which still occurs if the token is not set.

@g1eny0ung
Copy link
Member

/lgtm

I also fixed a problem where the auth interceptor needed to be reset before clearing the token. Other changes are LGTM. Thank you for the contribution, @jamshidi799!

@chaotic-prow chaotic-prow bot added the lgtm label Sep 27, 2023
@chaotic-prow
Copy link

chaotic-prow bot commented Sep 27, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: g1eny0ung

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

The pull request process is described here

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

@chaotic-prow chaotic-prow bot removed the lgtm label Sep 27, 2023
@chaotic-prow
Copy link

chaotic-prow bot commented Sep 27, 2023

New changes are detected. LGTM label has been removed.

@jamshidi799
Copy link
Contributor Author

/lgtm

I also fixed a problem where the auth interceptor needed to be reset before clearing the token. Other changes are LGTM. Thank you for the contribution, @jamshidi799!

Your welcome, Thank you for the review.

@g1eny0ung g1eny0ung added the lgtm label Sep 27, 2023
@chaotic-prow chaotic-prow bot merged commit fe094b8 into chaos-mesh:master Sep 27, 2023
26 checks passed
@g1eny0ung
Copy link
Member

/cherrypick release-2.6

@chaos-mesh-cherrypick-robot

@g1eny0ung: #4193 failed to apply on top of branch "release-2.6":

Applying: feat: remove token when get Unauthorized
Applying: update CHANGELOG.md
Using index info to reconstruct a base tree...
M	CHANGELOG.md
Falling back to patching base and 3-way merge...
Auto-merging CHANGELOG.md
CONFLICT (content): Merge conflict in CHANGELOG.md
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0002 update CHANGELOG.md
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherrypick release-2.6

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/test-infra repository.

g1eny0ung added a commit to g1eny0ung/chaos-mesh that referenced this pull request Sep 27, 2023
* feat: remove token when get Unauthorized

Signed-off-by: Mohammad Jamshidi <jamshidi.m799@gmail.com>

* update CHANGELOG.md

Signed-off-by: Mohammad Jamshidi <jamshidi.m799@gmail.com>

* fix: clear all connected caches

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: resetAPIAuthentication

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

---------

Signed-off-by: Mohammad Jamshidi <jamshidi.m799@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Co-authored-by: Yue Yang <g1enyy0ung@gmail.com>
g1eny0ung added a commit that referenced this pull request Sep 27, 2023
Signed-off-by: Mohammad Jamshidi <jamshidi.m799@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Co-authored-by: Yue Yang <g1enyy0ung@gmail.com>
wilcoweb pushed a commit to raymyers/chaos-mesh that referenced this pull request Nov 30, 2023
* feat: remove token when get Unauthorized

Signed-off-by: Mohammad Jamshidi <jamshidi.m799@gmail.com>

* update CHANGELOG.md

Signed-off-by: Mohammad Jamshidi <jamshidi.m799@gmail.com>

* fix: clear all connected caches

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

* fix: resetAPIAuthentication

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>

---------

Signed-off-by: Mohammad Jamshidi <jamshidi.m799@gmail.com>
Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
Co-authored-by: Yue Yang <g1enyy0ung@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically logout from dashboard when token expired
3 participants