系统自动生成代码 IdentityUser接口 (C:\Users\Administrator\AppData\Local\Temp\MetadataAsSource\2e2f25a54d90415084611cf559c8ce6a\bfc6c96e34c44a788c576ba209188bbe\IdentityUser.cs)
// #region 程序集 Microsoft.AspNet.Identity.EntityFramework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// D:\VS2017项目\Team2023\packages\Microsoft.AspNet.Identity.EntityFramework.2.2.2\lib\net45\Microsoft.AspNet.Identity.EntityFramework.dll
// #endregion
// using System;
// using System.Collections.Generic;
namespace Microsoft.AspNet.Identity.EntityFramework
{
public class IdentityUser<TKey, TLogin, TRole, TClaim> : IUser<TKey>
where TLogin : IdentityUserLogin<TKey>
where TRole : IdentityUserRole<TKey>
where TClaim : IdentityUserClaim<TKey>
{
public IdentityUser();
public virtual string Email { get; set; }
public virtual bool EmailConfirmed { get; set; }
public virtual string PasswordHash { get; set; }
public virtual string SecurityStamp { get; set; }
public virtual string PhoneNumber { get; set; }
public virtual bool PhoneNumberConfirmed { get; set; }
public virtual bool TwoFactorEnabled { get; set; }
public virtual DateTime? LockoutEndDateUtc { get; set; }
public virtual bool LockoutEnabled { get; set; }
public virtual int AccessFailedCount { get; set; }
public virtual ICollection<TRole> Roles { get; }
public virtual ICollection<TClaim> Claims { get; }
public virtual ICollection<TLogin> Logins { get; }
public virtual TKey Id { get; set; }
public virtual string UserName { get; set; }
}
}
自动生成代码 IdentityModels.cs ApplicationUser类 (D:\VS2017项目\Team2023\Team2023\Models\IdentityModels.cs)
// 可以通过将更多属性添加到 ApplicationUser 类来为用户添加配置文件数据,请访问 https://go.microsoft.com/fwlink/?LinkID=317594 了解详细信息。
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// 请注意,authenticationType 必须与 CookieAuthenticationOptions.AuthenticationType 中定义的相应项匹配
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// 在此处添加自定义用户声明
return userIdentity;
}
}
重写扩展 ApplicationUser 类
// 可以通过将更多属性添加到 ApplicationUser 类来为用户添加配置文件数据,请访问 https://go.microsoft.com/fwlink/?LinkID=317594 了解详细信息。
public class ApplicationUser : IdentityUser
{
/// <summary>
/// 员工姓名
/// </summary>
public string Name { get; set; }
/// <summary>
/// 备用电话
/// </summary>
public string PhoneNumber2 { get; set; }
/// <summary>
/// 员工QQ
/// </summary>
public string QQ { get; set; }
/// <summary>
/// 微信
/// </summary>
public string WeChat { get; set; }
/// <summary>
/// 钉钉
/// </summary>
public string DingDing { get; set; }
/// <summary>
/// 备用信息
/// </summary>
public string Note { get; set; }
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// 请注意,authenticationType 必须与 CookieAuthenticationOptions.AuthenticationType 中定义的相应项匹配
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// 在此处添加自定义用户声明
return userIdentity;
}