You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 13, 2020. It is now read-only.
Within my implementation of IAuthenticationProvider. I'm using Microsoft.AspNetCore.Identity to validate user and password.
And from what I know SignInManager and UserManager are registered as scope. But I agree that IAuthenticationProvider should be registered as Singleton as we don't need more than 1 instance of it.
So should I do: AddScoped<IAuthenticationProvider, CustomAuthenticationProvider>()
or what I think is a better solution, I will inject into CustomAuthenticationProvider, IServiceScopeFactory and do:
using (var scope = serviceScopeFactory.CreateScope()) { var signInManager = scope.ServiceProvider.GetService<SignInManager<ApplicationUser>>(); var userManager = scope.ServiceProvider.GetService<UserManager<ApplicationUser>>(); var findUser = await userManager.FindByNameAsync(user); var result = await signInManager.CheckPasswordSignInAsync(findUser, password, false); return result.Succeeded; }
Many thanks
The text was updated successfully, but these errors were encountered:
dienomb
changed the title
Quick question to validate the custom authentication using Microsoft.AspNetCore.Identity to do
Quick question to validate the custom authentication using Microsoft.AspNetCore.Identity
Jan 8, 2019
dienomb
changed the title
Quick question to validate the custom authentication using Microsoft.AspNetCore.Identity
Quick question to validate custom authentication using Microsoft.AspNetCore.Identity
Jan 8, 2019
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Within my implementation of IAuthenticationProvider. I'm using Microsoft.AspNetCore.Identity to validate user and password.
And from what I know SignInManager and UserManager are registered as scope. But I agree that IAuthenticationProvider should be registered as Singleton as we don't need more than 1 instance of it.
So should I do:
AddScoped<IAuthenticationProvider, CustomAuthenticationProvider>()
or what I think is a better solution, I will inject into CustomAuthenticationProvider, IServiceScopeFactory and do:
using (var scope = serviceScopeFactory.CreateScope()) { var signInManager = scope.ServiceProvider.GetService<SignInManager<ApplicationUser>>(); var userManager = scope.ServiceProvider.GetService<UserManager<ApplicationUser>>(); var findUser = await userManager.FindByNameAsync(user); var result = await signInManager.CheckPasswordSignInAsync(findUser, password, false); return result.Succeeded; }
Many thanks
The text was updated successfully, but these errors were encountered: