Consecutive team creations for the same user result in corrupted data
When creating multiple teams in parallel (with a Promise.all
), some of them don't end up in the user.teams
array.
Given that this array is (for the time being) fairly critical in my authsome mode, this results in broken functionality.
To reproduce:
- Clone the latest develop branch of the micropublication platform.
- Run
yarn setupdb
andyarn seed:demo
to create a few users. - Sign in as admin, go to the team manager and assign a user both as editor and science officer.
- Sign out and sign in as that user.
- Make a few new submissions.
If it all works, the user should see a submission form.
If it goes wrong, the user sees an empty preview of the article.
The problem is that the author team id for this article does not exist in the user's teams array, even though the author team includes the user's id.
To make things more complicated it doesn't always fail, though it fails more often than not.