Hi,
I have a situation where directly after a login attempt (an unsuccessfull one) the usermanager doesn't get the latest values from the database.
After running logInManager.LoginAsync() i see that the [AccessFailedCount]
is updated in the database. But when running userManager.FindByNameAsync() in the same function after the login, the values of the returned user are the ones from before the login attempt. Is this some kind of caching somewhere?
And how can I make sure to get the latest values.
I'm using the .net core & MVC version .
Regards, Robrecht
4 Answer(s)
-
0
Can you share some relevant code?
-
0
private async Task<AbpLoginResult<Tenant, User>> GetLoginResultAsync(string usernameOrEmailAddress, string password, string tenancyName) { var loginResult = await _logInManager.LoginAsync(usernameOrEmailAddress, password, tenancyName); if (loginResult.Result != AbpLoginResultType.Success) { var contact = _contactRepository.FindByUsernamePassword(usernameOrEmailAddress, password).FirstOrDefault(); if (contact != null) { var user = await _userManager.FindByNameAsync(usernameOrEmailAddress); } } }
In the code above, the user returned at the end returns the values from befere the
LoginAsync
. If I look in the database afterLoginAsync
the values are updated. -
0
hi robrechtbelien
Try using (var uow = _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew))
private async Task<AbpLoginResult<Tenant, User>> GetLoginResultAsync(string usernameOrEmailAddress, string password, string tenancyName) { var loginResult = await _logInManager.LoginAsync(usernameOrEmailAddress, password, tenancyName); if (loginResult.Result != AbpLoginResultType.Success) { using (var uow = _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew)) { var contact = _contactRepository. FindByUsernamePassword(usernameOrEmailAddress, password). FirstOrDefault(); if (contact != null) { var user = await _userManager.FindByNameAsync(usernameOrEmailAddress); } await uow.CompleteAsync(); } } }
-
0
Hi maliming,
That did the trick! Thanks!