aspnetboilerplate: Handling EF Core concurrency conflicts.

Abp 3.6 net core

https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp.ZeroCore/Authorization/AbpLoginManager.cs#L122

_logInManager.LoginAsync(context.UserName, context.Password, tenant);

This code occasionally throws a DbUpdateConcurrencyException exception under concurrency.

How to handle these internal Exceptions?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 22 (18 by maintainers)

Most upvoted comments

Is it possible to open a separate unit of work and disable the transaction and then assign a value to the User’s LastLoginTime?

Doesn’t matter. Because the problem occurs when multiple clients use the same username to login. So, it will still be conflict.

I think LastLoginTime is still very useful for users.

I think so. However, it’s not essential. Because UserLoginAttempt stores all login attempts. So, you can easily query this table to find the last successful login.

Would checking the User.Identity.IsAuthenticated flag sufficient to avoid this?

public async Task MockLogin()
{
	if (!User.Identity.IsAuthenticated)
	{
	    await _logInManager.LoginAsync("admin", "123qwe");
	}
}