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

BUG: Infinited loop with login #2039

Merged

Conversation

WalkerWang731
Copy link
Contributor

@WalkerWang731 WalkerWang731 commented Aug 7, 2024

Fixes #2021

Details:

  1. Added new keys auth and token in sessionStore to avoid conflicts with existing cookie key names.
  2. Optimized the authentication logic within each page. The new logic replaces the original code as follows:
if (!sessionStorage.getItem('auth') &&
    sessionStorage.getItem('token') !== 'no_auth' && cookie.token !== 'no_auth'
){
    navigate('/login', { replace: true });
}
  1. Updated the corresponding sessionStorage.setItem('token') / sessionStorage.setItem('auth') and sessionStorage.removeItem('token') / sessionStorage.removeItem('auth') logic accordingly.

@XprobeBot XprobeBot added the bug Something isn't working label Aug 7, 2024
@XprobeBot XprobeBot added this to the v0.14.0 milestone Aug 7, 2024
@qinxuye qinxuye changed the title FIX: Infinited loop with login BUG: Infinited loop with login Aug 8, 2024
@qinxuye qinxuye requested a review from yiboyasss August 8, 2024 02:20
@yiboyasss
Copy link
Contributor

When the user logs out and clicks the button in the upper left corner of the browser to return to the previous page, they should not enter the internal system.
截屏2024-08-09 11 53 26

@WalkerWang731
Copy link
Contributor Author

When the user logs out and clicks the button in the upper left corner of the browser to return to the previous page, they should not enter the internal system. 截屏2024-08-09 11 53 26

I have already fixed the relevant code and updated the logic to:

  if (
    sessionStorage.getItem('auth') === 'true' &&
    !isValidBearerToken(sessionStorage.getItem('token')) &&
    !isValidBearerToken(cookie.token)
  ) {
    navigate('/login', { replace: true })
  }

it's working now

@yiboyasss
Copy link
Contributor

After logging out, open a new page and enter the corresponding path. You should not enter the system.

@WalkerWang731
Copy link
Contributor Author

After logging out, open a new page and enter the corresponding path. You should not enter the system.

yes, now it can't access the system when clicked the logout button

@WalkerWang731
Copy link
Contributor Author

Hello, @yiboyasss @qinxuye
I'm aware of this PR has not been merged yet. May I know do you have any concerns about this PR now?
I've fixed the lastest problem that when clicking the logout button, the page can still be opened.
Here is the commit: 7704202

Any questions please let me know.
Thank you

@yiboyasss
Copy link
Contributor

We hope it's not a prompt to enter the page, but a direct inability to enter.
截屏2024-08-13 11 16 23

@WalkerWang731
Copy link
Contributor Author

We hope it's not a prompt to enter the page, but a direct inability to enter. 截屏2024-08-13 11 16 23

Hello @yiboyasss
I've fixed this problem
Please refer to the lastest commit: 7f7bd9b

Any questions please let me know
Thank you

@yiboyasss
Copy link
Contributor

After logging out, open a new page and enter the corresponding path. You should not enter the system.

A new question always has pop-up prompts, which are unnecessary.
截屏2024-08-14 10 30 20

@WalkerWang731
Copy link
Contributor Author

After logging out, open a new page and enter the corresponding path. You should not enter the system.

A new question always has pop-up prompts, which are unnecessary. 截屏2024-08-14 10 30 20

I've adjusted this part logic, please refer to the lastest commit: bb4aca1

@WalkerWang731 WalkerWang731 force-pushed the WalkerWang731/fix/infinited_login_loop branch from bb4aca1 to 7a8cc30 Compare August 14, 2024 05:06
@qinxuye qinxuye merged commit 3540f2b into xorbitsai:main Aug 15, 2024
10 of 13 checks passed
@qinxuye
Copy link
Contributor

qinxuye commented Aug 15, 2024

Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

前端页面无限跳转登录页问题
4 participants