华恒Mes鼎捷代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.2 KiB

5 months ago
  1. using System.Security.Claims;
  2. using System.Threading.Tasks;
  3. using Microsoft.AspNet.Identity;
  4. using Microsoft.AspNet.Identity.EntityFramework;
  5. using Microsoft.AspNet.Identity.Owin;
  6. namespace WebApplication1.Models
  7. {
  8. // 可以通过向 ApplicationUser 类添加更多属性来为用户添加个人资料数据,若要了解详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=317594。
  9. public class ApplicationUser : IdentityUser
  10. {
  11. public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager, string authenticationType)
  12. {
  13. // 请注意,authenticationType 必须与 CookieAuthenticationOptions.AuthenticationType 中定义的相应项匹配
  14. var userIdentity = await manager.CreateIdentityAsync(this, authenticationType);
  15. // 在此处添加自定义用户声明
  16. return userIdentity;
  17. }
  18. }
  19. public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
  20. {
  21. public ApplicationDbContext()
  22. : base("DefaultConnection", throwIfV1Schema: false)
  23. {
  24. }
  25. public static ApplicationDbContext Create()
  26. {
  27. return new ApplicationDbContext();
  28. }
  29. }
  30. }