AspNetCore.Identity.Mongo icon indicating copy to clipboard operation
AspNetCore.Identity.Mongo copied to clipboard

UpdateUserAsync not properly saving data in Hosted Service

Open pippinmole opened this issue 3 years ago • 1 comments

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):

  • .NET 6
  • AspNetCore.Identity.Mongo v8.3.3 image

Additional context Add any other context about the problem here.

pippinmole avatar Feb 22 '22 01:02 pippinmole

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

image image

pippinmole avatar Feb 22 '22 13:02 pippinmole