matteofabbri / AspNetCore.Identity.Mongo

This is a MongoDB provider for the ASP.NET Core 2 Identity framework
https://matteofabbri.org
MIT License
340 stars 88 forks source link

UpdateUserAsync not properly saving data in Hosted Service #121

Open pippinmole opened 2 years ago

pippinmole commented 2 years ago

Describe the bug When setting the username of a user, updating it (through userManager.UpdateUserAsync(user)), the user data is not stored. This is clearly shown in the screenshot where I get the user straight after, to which the names do not match, but sometimes they do?

image

It is worth noting I am using Cronos, a cron-style scheduling package that allows me to run background tasks every period of time.

To Reproduce Steps to reproduce the behavior:

  1. Register a Cronos job inheriting from the CronJobService
  2. Inside DoWork, await a delay and try and update the user
  3. Observe the property you update not reliably being updated

Expected behavior User gets updated every time the method is called and awaited

Screenshots

image image image

Environment (please complete the following information):

Additional context Add any other context about the problem here.

pippinmole commented 2 years ago

It may be worth noting that if I change the IAppUserManager (my interface) to UserManager (MongoDB .NET library), it still produces this error, as shown in the images below

image image