Guest User

Untitled

a guest
Jun 1st, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. public class ApplicationUser : IdentityUser
  2. {
  3. public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
  4. {
  5. // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
  6. var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
  7. // Add custom user claims here
  8. return userIdentity;
  9. }
  10.  
  11. public Customer Customer { get; set; }
  12. [Required]
  13. public int CustomerId { get; set; }
  14. }
  15.  
  16. public async System.Threading.Tasks.Task<bool> AddAccount(string email, int customerId)
  17. {
  18. // Asp.net User
  19. var user = await UserManager.FindByEmailAsync(email);
  20. string password = Membership.GeneratePassword(5, 1);
  21. if (user == null)
  22. {
  23. user = new ApplicationUser { UserName = email, Email = email, CustomerId = customerId };
  24. var result = await UserManager.CreateAsync(user, password);
  25. if (!result.Succeeded)
  26. {
  27. return false;
  28. }
  29. }
  30.  
  31. return true;
  32. }
Add Comment
Please, Sign In to add comment