重构代码
重构代码
This commit is contained in:
@@ -30,7 +30,7 @@ namespace Yi.Framework.WebCore
|
||||
/// </summary>
|
||||
/// <param name="httpContext"></param>
|
||||
/// <returns></returns>
|
||||
public static user GetCurrentUserInfo(this HttpContext httpContext, out List<int> menuIds)
|
||||
public static User GetCurrentUserInfo(this HttpContext httpContext, out List<int> menuIds)
|
||||
{
|
||||
IEnumerable<Claim> claimlist = httpContext.AuthenticateAsync().Result.Principal.Claims;
|
||||
|
||||
@@ -40,22 +40,22 @@ namespace Yi.Framework.WebCore
|
||||
menuIds = claimlist.Where(u => u.Type == "menuIds").ToList().Select(u => Convert.ToInt32(u.Value)).ToList();
|
||||
|
||||
|
||||
return new user()
|
||||
return new User()
|
||||
{
|
||||
id = resId,
|
||||
username = claimlist.FirstOrDefault(u => u.Type == ClaimTypes.Name).Value ?? "匿名"
|
||||
Id = resId,
|
||||
Username = claimlist.FirstOrDefault(u => u.Type == ClaimTypes.Name).Value ?? "匿名"
|
||||
};
|
||||
}
|
||||
public static user GetCurrentUserInfo(this HttpContext httpContext)
|
||||
public static User GetCurrentUserInfo(this HttpContext httpContext)
|
||||
{
|
||||
IEnumerable<Claim> claimlist = httpContext.AuthenticateAsync().Result.Principal.Claims;
|
||||
|
||||
Int32.TryParse(claimlist.FirstOrDefault(u => u.Type == ClaimTypes.Sid).Value, out int resId);
|
||||
|
||||
return new user()
|
||||
return new User()
|
||||
{
|
||||
id = resId,
|
||||
username = claimlist.FirstOrDefault(u => u.Type == ClaimTypes.Name).Value ?? "匿名"
|
||||
Id = resId,
|
||||
Username = claimlist.FirstOrDefault(u => u.Type == ClaimTypes.Name).Value ?? "匿名"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user