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

fix: Redirect user to login if session is terminated #49208

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Nov 11, 2024

Summary

If a session timed out or was closed in another tab, then currently the user gets random error messages. This intercepts 401 responses (should only happen if logged out, or the users does something wrong).

If we get a 401, we make sure its because of the session, by checking if the user can access the files app.
If that is also the case we forward the user to the login page and set the redirect URL to the last used URL.

Screen recording

Bildschirmaufnahme_20241111_174951.webm

Checklist

@susnux susnux requested review from julien-nc, Pytal, a team, artonge and nfebe and removed request for a team November 11, 2024 17:26
@susnux
Copy link
Contributor Author

susnux commented Nov 11, 2024

/backport to stable30

@susnux
Copy link
Contributor Author

susnux commented Nov 11, 2024

/backport to stable29

Copy link
Contributor

@artonge artonge left a comment

Choose a reason for hiding this comment

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

Shouldn't this be added to the @nextcloud/axios lib?
But is the webdav lib using @nc/axios?

@susnux
Copy link
Contributor Author

susnux commented Nov 13, 2024

Shouldn't this be added to the @nextcloud/axios lib?

No, similar as the other interceptors, this is not a feature developers can opt-in with using nc-axios, but it is a core feature.
Meaning it should work for all requests, even if you just use vanilla JavaScript.

@susnux susnux requested a review from artonge November 16, 2024 21:01
If a session timed out or was closed in another tab,
then currently the user gets random error messages.
This intercepts 401 responses (should only happen if logged out, or the
users does something wrong).

If we get a 401, we make sure its because of the session,
by checking if the user can access the files app.
If that is also the case we forward the user to the login page
and set the redirect URL to the last used URL.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@susnux susnux force-pushed the fix/forward-user-login-if-no-session branch from 1d1cb05 to 8f5c8e1 Compare November 17, 2024 00:35
@susnux
Copy link
Contributor Author

susnux commented Nov 17, 2024

Tests added.

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.

[Bug]: Getting Unexpected error: Invalid response 401 in Files app
3 participants