title: How to save user last login date if he was logged in with external login provider using ASP .Net Identity?
body: <p>I've extended <code>AspNetUser</code> class with <code>LastLoginDate</code> property to remember each time user makes login. </p>
  
  <pre><code>public sealed partial class User : IdentityUser&lt;int, UserLogin, UserRole, UserClaim&gt;, IUser&lt;int&gt;, IDatabaseEntity
  {
      ...
      public DateTime? LastLoginDate { get; set; }   
  }
  </code></pre>
  
  <p>Loging works fine each time user makes usual login using email and password as login credentials. In <code>AccountController</code> I have my login action:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Login(LoginModel model)
  {
      ...
      var result = SignInManager.PasswordSignIn(model.Email, model.Password, model.RememberMe);
  
      if (result == SignInStatus.Success)
      {
          var user = UserManager.FindByEmail(email);
          UserManager.RememberLoginDate(user);  
          return Redirect(model.ReturnUrl);
      }
  
      ...
  }
  </code></pre>
  
  <p><code>RememberLoginDate</code> is just an extension methods which basically just sets current time to user <code>LastLoginDate</code>  property:</p>
  
  <pre><code>public static IdentityResult RememberLoginDate(this ApplicationUserManager manager, User user)
  {
       user.LastLoginDate = DateTime.UtcNow;;
       return manager.Update(user);
  }
  </code></pre>
  
  <p>But when I do external login like below:</p>
  
  <pre><code>[AllowAnonymous]
  public ActionResult ExternalLoginCallback(string returnUrl, string provider)
  {
       var loginInfo = AuthenticationManager.GetExternalLoginInfo();
       if (loginInfo == null)
            return RedirectToAction("ExternalLoginFail");
  
       // Sign in the user with this external login provider if the user already has a login
       var result = SignInManager.ExternalSignIn(loginInfo);
       if (result == SignInStatus.Success)
            return RedirectToLocal(returnUrl);
  
       if (result == SignInStatus.Failure)
       {
            return View("ExternalLoginConfirmation" ...) 
       }
  
       ...
  }
  </code></pre>
  
  <p>How can I log user login date in this case? I have no info about the user such as <code>email</code> or <code>Id</code> to get him with <code>UserManager</code> at this point. I've already tried: <code>User.Identity.GetUserId&lt;int&gt;()</code> to get user <code>Id</code> after <code>SignInManager.ExternalSignIn(loginInfo)</code> but it is not updated after login, it still is <code>default(int)</code> - <code>0</code>. <code>SignInStatus</code> is just an <code>enum</code> with no additional info about the logged user and use <code>ExternalLoginInfo.Email</code> is also not an option because this email can be different from user's actual registered email.</p>