Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. var claims = new List<Claim>();
  2. claims.Add(new Claim(ClaimTypes.Name, "Brock"));
  3. claims.Add(new Claim(ClaimTypes.Email, "brockallen@gmail.com"));
  4. var id = new ClaimsIdentity(claims,DefaultAuthenticationTypes.ApplicationCookie);
  5.  
  6. var ctx = Request.GetOwinContext();
  7. var authenticationManager = ctx.Authentication;
  8. authenticationManager.SignIn(id);
  9.  
  10. // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
  11. var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
  12.  
  13. // Add custom user claims here
  14.  
  15. return userIdentity;
  16.  
  17. // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
  18. var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
  19.  
  20. // Add custom user claims here
  21. userIdentity.AddClaim(new Claim("myCustomClaim", "value of claim"));
  22.  
  23. return userIdentity;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement