wefork / wekan

The open-source Trello-like kanban (built with Meteor)
https://wekan.io
MIT License
61 stars 12 forks source link

Profile ocassionally does not attach to user #15

Closed mario-orlicky closed 7 years ago

mario-orlicky commented 7 years ago

There is a problem after logout/login the profile schema is not attached to the user. This unfortunately happens only sometimes, the refresh solves the problem. Open dev tools and check with Meteor.user().profile, probably the full profile shown only with 'invitedBoards' property is returned. Try to relogin, check the profile again. If property still visible then try again. It usually happens after first relogin to me, but used to happen on the third one as well..

EDIT: If reproduced the issue notice that this also causes shortcuts for starred boards to dissapear, which are also stored in the profile

dwrensha commented 7 years ago

I am able to reproduce this problem. It seems that there is an unfortunate interaction between three things:

  1. Meteor's built-in logic that subscribes a user to their own Users record, including the full profile field.
  2. Wekan's 'board' publication, which relies on some complicated magic from the cottz:publish-relations package to publish partial profiles for all members of a board. Somehow this seems to overwrite the profile data that the client receives from (1).
  3. Wekan's usage of SubsManager, which implies that subscriptions to 'board' don't get stopped when the user navigates away.
dwrensha commented 7 years ago

20 works around the problem.

dwrensha commented 7 years ago

21 works around the problem and seems less likely than #20 to cause other problems.

Of course, it still would be good to understand the root problem here! I suspect there is a bug in the cottz:publish-relations package.

xet7 commented 7 years ago

Some errors on current version of pull request https://github.com/wefork/wekan/pull/20

dwrensha commented 7 years ago

I believe the main problem is that this cursor will call subscription.added() with an incomplete version of the user's profile. If that call to added() happens before Meteor's autopublish of user.profile happens, then it is the only piece of the profile that the client will see. #25 fixes this problem by avoiding the current user in this 'boards' publish.

dwrensha commented 7 years ago

Fixed by #25.