title: How to Extend SignInManager in .net Core 2.0
body: <p>I have set up a new property in my User class (IsEnabled) and want the sign in manager to check this, so I am overriding PasswordSignInAsync as follows:</p>
  
  <pre><code>public class AuthSignInManager&lt;TUser&gt; : SignInManager&lt;User&gt; where TUser : class
  {
      private readonly UserManager&lt;User&gt; _userManager;
      private readonly AuthContext _db;
      private readonly IHttpContextAccessor _contextAccessor;
  
      public AuthSignInManager(
          UserManager&lt;User&gt; userManager, 
          IHttpContextAccessor contextAccessor, 
          IUserClaimsPrincipalFactory&lt;User&gt; claimsFactory, 
          IOptions&lt;IdentityOptions&gt; optionsAccessor, 
          ILogger&lt;SignInManager&lt;User&gt;&gt; logger, 
          AuthContext dbContext,
          IAuthenticationSchemeProvider schemeProvider
          )
          : base(userManager, contextAccessor, claimsFactory, optionsAccessor, logger, schemeProvider)
      {
          _userManager = userManager ?? throw new ArgumentNullException(nameof(userManager));
          _contextAccessor = contextAccessor ?? throw new ArgumentNullException(nameof(contextAccessor));
          _db = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
      }
  
      public override Task&lt;SignInResult&gt; PasswordSignInAsync(string userName, string password, bool rememberMe, bool shouldLockout)
      {
          var user = UserManager.FindByEmailAsync(userName).Result;
  
          if ((user.IsEnabled.HasValue &amp;&amp; !user.IsEnabled.Value) || !user.IsEnabled.HasValue)
          {
              return Task.FromResult(SignInResult.LockedOut);
          }
  
          return base.PasswordSignInAsync(userName, password, rememberMe, shouldLockout);
      }
  }
  </code></pre>
  
  <p>I have put the following in startup:</p>
  
  <pre><code>        services.AddIdentity&lt;User, IdentityRole&gt;(config =&gt;
              {
                  config.SignIn.RequireConfirmedEmail = true;
              })
              .AddEntityFrameworkStores&lt;AuthContext&gt;()
              .AddDefaultTokenProviders()
              .AddUserManager&lt;AuthSignInManager&lt;User&gt;&gt;();
  
          services.AddScoped&lt;SignInManager&lt;User&gt;, AuthSignInManager&lt;User&gt;&gt;();
  </code></pre>
  
  <p>But when I run my project now I get the following error:
  <a href="https://i.stack.imgur.com/ocnS7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ocnS7.png" alt="enter image description here"></a>
  What am I doing wrong?</p>