chore(client): stop replacing Meteor.user#32910
Conversation
|
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #32910 +/- ##
========================================
Coverage 55.53% 55.53%
========================================
Files 2637 2637
Lines 57439 57443 +4
Branches 11903 11906 +3
========================================
+ Hits 31897 31900 +3
+ Misses 22823 22822 -1
- Partials 2719 2721 +2
Flags with carried forward coverage won't be shown. Click here to find out more. |
apps/meteor/app/ui-cached-collection/client/models/CachedCollectionManager.ts
Outdated
Show resolved
Hide resolved
Meteor.userMeteor.user
ce1d5b1 to
e107adf
Compare
| const userId = useUserId(); | ||
| useEffect(() => { | ||
| if (!userId) { | ||
| return; | ||
| } | ||
|
|
||
| router.navigate( | ||
| { | ||
| pathname: '/home', | ||
| }, | ||
| { replace: true }, | ||
| ); | ||
| }, [userId, router]); | ||
|
|
There was a problem hiding this comment.
Just trying to understand: why are we removing this?
Shouldn't we keep redirecting the user to the homepage in case they are already logged in RC when accessing this page?
There was a problem hiding this comment.
Pierre had done a workaround, for some reason, in Meteor 3.0.0 this callback would never be called. However, in Meteor 2.0.0 it happens.
If you stop to think about it, it doesn't make sense to redirect the user after logging in if he doesn't have a uid, because that means it failed.
Likewise, it doesn't make sense to redirect twice if it works.
You even did a test to see if it redirects to the home page twice, that's going to be quite interesting.
There was a problem hiding this comment.
Looking at this file now, one thing that I find weird is that we're doing the redirects (to home or to redirectUrl) even if the callback is called with an error. Shouldn't this happen only on successful login (specially for the redirectUrl)?
I think we should add an extra test forcing some kind of error to happen on this last step of the login method to ensure the client is behaving as it should.
We have e2e tests for errors on loginWithSaml, but none with errors on loginWithSamlToken. On the unit tests for the view, the mocked function never sends any errors.
…ove/threadMetrics * 'develop' of github.com:RocketChat/Rocket.Chat: (26 commits) chore: Bump rocket.chat to 6.12.0-develop (#32936) test: Move Jest configuration to a package of presets (#32802) chore: bump turbo (#32938) feat: New users page deactivated tab and active tab ui (#32032) chore: bump traefik (#32892) test: fix flaky test `Archive department` (#32933) fix(Livechat): `After Registration Triggers` showing in wrong screen (#32928) refactor: Remove deprecated `Options.AvatarSize` constant (#32909) chore: improve `on login` cached collection (#32929) i18n: Rocket.Chat language update from Lingohub 🤖 on 2024-07-25Z (#32908) refactor: Circular imports (#32885) regression: notify user properly on logout (#32920) chore(client): stop replacing `Meteor.user` (#32910) regression: Messagebox sending message instead of just selecting popup suggestion (#32890) refactor: move broadcastMessageFromData to notifyListener (#32843) chore: prevent destructuring _id of deleted users (#32899) ci: increase kernel limits (#32902) ci: lint issues Release 6.10.1 fix: imported fixes (#32894) ...
After a change in Meteor (meteor 3.0.0), where
Accounts.callLoginMethodtrusts thatAccounts.user.findis still there to call the login callbacks, it became clear that it is not healthy to rewrite internal framework objects....
...
But no one has proof that adding extra methods causes problems :)
Proposed changes (including videos or screenshots)
Issue(s)
Steps to test or reproduce
Further comments
CORE-578