Advertisement
Guest User

Untitled

a guest
Sep 10th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. public virtual int AccessFailedCount { get; set; }
  2.  
  3. public virtual ICollection<TClaim> Claims { get; }
  4.  
  5. public virtual string Email { get; set; }
  6.  
  7. public virtual bool EmailConfirmed { get; set; }
  8.  
  9. public virtual TKey Id { get; set; }
  10.  
  11. public virtual bool LockoutEnabled { get; set; }
  12.  
  13. public virtual DateTime? LockoutEndDateUtc { get; set; }
  14.  
  15. public virtual ICollection<TLogin> Logins { get; }
  16.  
  17. public virtual string PasswordHash { get; set; }
  18.  
  19. public virtual string PhoneNumber { get; set; }
  20.  
  21. public virtual bool PhoneNumberConfirmed { get; set; }
  22.  
  23. public virtual ICollection<TRole> Roles { get; }
  24.  
  25. public virtual string SecurityStamp { get; set; }
  26.  
  27. public virtual bool TwoFactorEnabled { get; set; }
  28.  
  29. public virtual string UserName { get; set; }
  30.  
  31. public class ApplicationUser : IdentityUser
  32. {
  33. public bool Has_accepted_policy { get; set; }
  34. public int user_type_id { get; set; }
  35. }
  36.  
  37. public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
  38. {
  39. public ApplicationDbContext()
  40. : base("DefaultConnection")
  41. {
  42.  
  43. }
  44. }
  45.  
  46. public string Id { get; set; }
  47.  
  48. [Required]
  49. [StringLength(256)]
  50. public string UserName { get; set; }
  51.  
  52. public string PasswordHash { get; set; }
  53.  
  54. public string SecurityStamp { get; set; }
  55.  
  56. [StringLength(256)]
  57. public string Email { get; set; }
  58.  
  59. public bool EmailConfirmed { get; set; }
  60.  
  61. public bool Is_Active { get; set; }
  62.  
  63. [Required]
  64. [StringLength(128)]
  65. public string Discriminator { get; set; }
  66.  
  67. public int? user_type_id { get; set; }
  68.  
  69. public bool Has_accepted_policy { get; set; }
  70.  
  71. public string PhoneNumber { get; set; }
  72.  
  73. public bool PhoneNumberConfirmed { get; set; }
  74.  
  75. public bool TwoFactorEnabled { get; set; }
  76.  
  77. public DateTime? LockoutEndDateUtc { get; set; }
  78.  
  79. public bool LockoutEnabled { get; set; }
  80.  
  81. public int AccessFailedCount { get; set; }
  82.  
  83. ... other virtual properties
  84.  
  85. IdentityResult result = await UserManager.CreateAsync(user, model.Password);
  86.  
  87. UserManagerFactory = () => new UserManager<ApplicationUser>(new UserStore<ApplicationUser>());
  88.  
  89. public AccountController()
  90. : this(Startup.UserManagerFactory(), Startup.OAuthOptions.AccessTokenFormat)
  91. {
  92. }
  93.  
  94. public AccountController(UserManager<ApplicationUser> userManager,
  95. ISecureDataFormat<AuthenticationTicket> accessTokenFormat)
  96. {
  97. UserManager = userManager;
  98. AccessTokenFormat = accessTokenFormat;
  99. }
  100.  
  101. public UserManager<ApplicationUser> UserManager { get; private set; }
  102.  
  103. UserManagerFactory = () => new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
  104.  
  105. UserManagerFactory = () => new UserManager<ApplicationUser>(new UserStore<ApplicationUser>());
  106.  
  107. UserManagerFactory = () => new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
  108.  
  109. <add name="MyConnString" connectionString="Data Source=server; Initial Catalog=db_name; User ID=user_id; Password=password; Connect Timeout=60;" providerName="System.Data.SqlClient" />
  110.  
  111. public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
  112. {
  113. public ApplicationDbContext()
  114. : base("MyConnString")
  115. {
  116. }
  117. }
  118.  
  119. public class ApplicationUserManager : UserManager<ApplicationUser> // the name conflict
  120. {
  121. public ApplicationUserManager(IUserStore<ApplicationUser> store)
  122. : base(store)
  123. {
  124. }
  125.  
  126. <add name="DefaultConnection" connectionString="Server=qadb.myserver.com;Database=mydb;User Id=myuser;Password=mypass;" providerName="System.Data.SqlClient" />
  127.  
  128. public partial class GoldfishDbContext : IdentityDbContext<ApplicationUser>
  129. {
  130. ....
  131. }
  132.  
  133. builder.RegisterType<ApplicationUserManager>().InstancePerRequest();
  134.  
  135. public ApplicationUserManager UserManager
  136. {
  137. get
  138. {
  139. return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
  140. }
  141. private set
  142. {
  143. _userManager = value;
  144. }
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement