Skip to content

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

Merged
skjnldsv merged 2 commits into
masterfrom
fix/forward-user-login-if-no-session
Dec 20, 2024
Merged

fix: Redirect user to login if session is terminated#49208
skjnldsv merged 2 commits into
masterfrom
fix/forward-user-login-if-no-session

Conversation

@susnux

@susnuxsusnux commented Nov 11, 2024

Copy link
Copy Markdown
Contributor

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 a team, Pytal, artonge, julien-nc and nfebe and removed request for a teamNovember 11, 2024 17:26
@susnux

Copy link
Copy Markdown
ContributorAuthor

/backport to stable30

@susnux

Copy link
Copy Markdown
ContributorAuthor

/backport to stable29

@artongeartonge left a comment

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
ContributorAuthor

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.

Comment threadcore/src/utils/xhr-request.js Outdated
@susnux
susnux requested a review from artongeNovember 16, 2024 21:01
@susnux
susnuxforce-pushed the fix/forward-user-login-if-no-session branch from 1d1cb05 to 8f5c8e1CompareNovember 17, 2024 00:35
@susnux

Copy link
Copy Markdown
ContributorAuthor

Tests added.

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>
@skjnldsv
skjnldsvforce-pushed the fix/forward-user-login-if-no-session branch from 8f5c8e1 to 1df2314CompareDecember 19, 2024 17:56
@skjnldsv

Copy link
Copy Markdown
Member

/compile

Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
@skjnldsvskjnldsv mentioned this pull request Jan 7, 2025
@inet-cologne

Copy link
Copy Markdown

@susnux , @skjnldsv , @artonge , @Pytal
Hey guys,
may it be that the change made here in #49560 or #49208 produces somehow login problems within Nextcloud files app, Nextcloud Talk app and perhaps causing issues with Calendar subscription synchronising?
Since a couple of days after updating (several instances!!) Nextcloud Server to 30.0.5, problems were occurring that Login fails. These could be fixed by deleting and reinstalling and reconfiguring the apps.
30.0.6 does not fix the situation either but now even reinstallation does not help anymore.
Login with the above mentioned iOS apps are not possible any more!!
Please see issue #50619!

Thanks for checking that!!
Chris

@inet-cologne

Copy link
Copy Markdown

@susnux , @skjnldsv , @artonge , @Pytal
Hey guys, could you pleeeease check this?
Thanks a lot!!

@jolly-jump

Copy link
Copy Markdown

@susnux , @skjnldsv , @artonge , @Pytal
Hey guys,

can you please check, if you are experiencing the login problems as well?
There are some github issues and forum-threads that seem to fit.
I did some summary: https://help.nextcloud.com/t/first-login-with-desktop-ios-android-app-fails/223854
I have no clue, why this happens to "us" and not to everyone as it seems.

Thanks!

@jolly-jump

Copy link
Copy Markdown

@susnux , @skjnldsv , @artonge , @Pytal Hey guys, could you pleeeease check this? Thanks a lot!!

Hi again,
I figured, that our login-rejection problem might be connected to using LDAP/AD as authenticator.

Can you rule out that your code changes here could lead to login-problem in combination with LDAP/AD? Did you test your changes with such a setting?

Thanks!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

7 participants

@susnux@skjnldsv@inet-cologne@jolly-jump@artonge@Pytal@nextcloud-command