title: ASP.NET Identity, multiple users with the same username, but belonging to different companies. Override FindAsync?
body: <p>I'm new with MVC and EF, and I'm working on a project where I use Identity for user and role management. In the predefined login function from Visual Studio there's a function named FindAsync, used to get the user by username and password. In my case there can be more than one user with the same username and password, but they will belong to different companies. I would like to know the best approach; should I override the FindAsync function (and other functions if necessary) and add another parameter, or should I implement user and role management myself, without Identity? Or is there another, even better solution?</p>
  
  <p>If the best solution is to override the function, then I'm a bit unsure of how I should do it, since the source code for UserManager is not yet open.</p>
  
  <p>Below you can find the login function and takeouts from my models:</p>
  
  <pre><code>    public async Task&lt;ActionResult&gt; Login(Login model, string returnUrl)
      {
          if (ModelState.IsValid)
          {
              var user = await UserManager.FindAsync(model.UserName, model.Password);
              if (user != null)
              {
                  await SignInAsync(user, model.RememberMe);
                  return RedirectToLocal(returnUrl);
              }
              else
              {
                  ModelState.AddModelError("", "Invalid username or password.");
              }
          }
  
          // If we got this far, something failed, redisplay form
          return View(model);
      }
  
  public class Company
  {
      public int Id { get; set; }
      [Required]
      public string Name { get; set; }
      public virtual ICollection&lt;User&gt; Users { get; set; }
      public virtual ICollection&lt;Role&gt; Roles { get; set; }
  }
  
  public class User : IdentityUser
  {
      public string FirstName { get; set; }
      public string LastName { get; set; }
      [Required]
      public virtual int CompanyId { get; set; }
      [Required]
      public virtual Company Company { get; set; }
  }
  </code></pre>
  
  <p>Any help is more than welcome!</p>