using LiveForum.Code.Utility; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Security.Claims; using System.Text; using System.Threading.Tasks; namespace LiveForum.Code.JwtInfrastructure { public class JwtUserInfoModel { /// /// 用户id /// public string UserName { get; set; } /// /// /// public List Claims { get; set; } /// /// 过期时间 /// public DateTime ExpireAt { get; set; } private int? _userId = null; /// /// 用户Id /// public int UserId { get { if (_userId != null && _userId != 0) { return _userId ?? 0; } if (Claims != null && Claims.Count > 0) { _userId = Claims.FirstOrDefault(x => x.Type == "userId")?.Value.toint(0) ?? 0; } else { _userId = 0; } return _userId ?? 0; } } private int? _loginType = null; /// /// 登录类型 /// public int LoginType { get { if (_loginType != null && _loginType != 0) { return _loginType ?? 0; } if (Claims != null && Claims.Count > 0) { _loginType = Claims.FirstOrDefault(x => x.Type == "loginType")?.Value.toint(0) ?? 0; } else { _loginType = 0; } return _loginType ?? 0; } } } }