title: Add Claim On Successful Login
body: <p>I need to add a claim to the user's identity after a successful user login. This is where I think it needs to happen:</p>
  
  <pre><code>public async Task&lt;ActionResult&gt; Login(LoginViewModel model, string returnUrl, string myClaimValue)
  {
     if (!ModelState.IsValid)
     {
        return View(model);
     }
  
     var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false);
     switch (result)
     {
        case SignInStatus.Success:
           UserManager.AddClaim(User.Identity.GetUserId(), new Claim("MyClaim", myClaimValue));
           return RedirectToLocal(returnUrl);
        case SignInStatus.LockedOut:
           return View("Lockout");
        case SignInStatus.RequiresVerification:
           return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
        case SignInStatus.Failure:
        default:
           ModelState.AddModelError("", "Invalid login attempt.");
           return View(model);
     }
  }
  </code></pre>
  
  <p>I think this is the right approach, but the call to <code>User.Identity.GetUserId()</code> throws an exception. It looks like <code>User.Identity</code> is not updated by the successful signin. In lieu of this reality, what is the best way for me to get the newly signed in user's id so that I can add a claim?</p>
  
  <p>Or am I doing this all wrong?</p>