title: Asp.NET Identity Custom SignInManager
body: <p>In my application, I would like to add additional conditions in order for users to login.  For example, the Admin is allowed to "lock" a user account, for some reason.  When account is locked, the user cannot log in.  Note that this is different for the "lock out" due to multiple failed login attempts.  The lock condition could be removed by the Admin.</p>
  
  <p>I see that the default template creates a ApplicationSignInManager that derives from the default.</p>
  
  <pre><code>public class ApplicationSignInManager : SignInManager&lt;User, string&gt;
  </code></pre>
  
  <p>The "Login" action from the "Account" controller calls</p>
  
  <pre><code>var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
  </code></pre>
  
  <p>So my attempt is to override this function</p>
  
  <pre><code>public override async Task&lt;SignInStatus&gt; PasswordSignInAsync(string userName, string password, bool isPersistent, bool shouldLockout)
  {
      User user = this.UserManager.FindByName(userName);
      if (null != user)
      {
          if (true == user.AccountLocked)
          {
              return (SignInStatus.LockedOut);
          }
      }
  
      var result = await base.PasswordSignInAsync(userName, password, isPersistent, shouldLockout);
  
      return (result);
  }
  </code></pre>
  
  <p>There are 2 problems with this.  First, this assumes that the "userName" is unique for each user.  Although, this could be safely assumed.</p>
  
  <p>Second, the function returns practically a SignInStatus, which is defined by the Asp.net Identity.  I cannot modify to return anything else, to convey proper reason why the login may fail.</p>
  
  <p>Could anyone provide good solutions to this?</p>