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] Race conditions on/before login #16989

Merged
merged 1 commit into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/authorization/client/startup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';

import { hasAtLeastOnePermission } from './hasPermission';
import { CachedCollectionManager } from '../../ui-cached-collection';
Expand Down Expand Up @@ -28,5 +29,12 @@ Meteor.startup(() => {
},
removed: (role) => Roles.remove({ _id: role.name }),
};
rolesStreamer.on('roles', (role) => events[role.type](role));

Tracker.autorun((c) => {
if (!Meteor.userId()) {
return;
}
rolesStreamer.on('roles', (role) => events[role.type](role));
c.stop();
});
});
3 changes: 3 additions & 0 deletions app/ui-sidenav/client/userPresence.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ Tracker.autorun(() => {
});

Template.userPresence.onRendered(function() {
if (!this.data || !this.data.uid) {
return;
}
data.set(this.firstNode, this.data);
if (featureExists) {
return observer.observe(this.firstNode);
Expand Down
7 changes: 4 additions & 3 deletions app/webdav/client/startup/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ const events = {
};

Tracker.autorun(async () => {
if (Meteor.userId()) {
const { accounts } = await APIClient.v1.get('webdav.getMyAccounts');
accounts.forEach((account) => WebdavAccounts.insert(account));
if (!Meteor.userId()) {
return;
}
const { accounts } = await APIClient.v1.get('webdav.getMyAccounts');
accounts.forEach((account) => WebdavAccounts.insert(account));
Notifications.onUser('webdav', ({ type, account }) => events[type](account));
});
2 changes: 1 addition & 1 deletion client/lib/userData.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const isSyncReady = new ReactiveVar(false);

function updateUser(userData) {
const user = Users.findOne({ _id: userData._id });
if (!user || userData._updatedAt > user._updatedAt.toISOString()) {
if (!user || !user._updatedAt || userData._updatedAt > user._updatedAt.toISOString()) {
userData._updatedAt = new Date(userData._updatedAt);
return Meteor.users.upsert({ _id: userData._id }, userData);
}
Expand Down