Esempio n. 1
0
 /// <summary>
 /// 使用cookie登录
 /// </summary>
 public static void CookieLogin(this HttpContext context, LoginUserInfo loginuser) =>
 context.RequestServices.Resolve_ <IAuthDataProvider>().SetToken(loginuser.LoginToken);
Esempio n. 2
0
 /// <summary>
 /// 判断用户是否有权限
 /// </summary>
 public static bool HasPermission(this LoginUserInfo loginuser, string permission) =>
 ValidateHelper.IsPlumpList(loginuser.Permissions) && loginuser.Permissions.Contains(permission);
Esempio n. 3
0
 /// <summary>
 /// 去除权限等敏感信息
 /// </summary>
 public static void ClearPrivateInfo(this LoginUserInfo loginuser)
 {
     loginuser.Roles?.Clear();
     loginuser.Permissions?.Clear();
 }
Esempio n. 4
0
 /// <summary>
 /// 判断用户是否有角色
 /// </summary>
 /// <param name="loginuser"></param>
 /// <param name="role"></param>
 /// <returns></returns>
 public static bool HasRole(this LoginUserInfo loginuser, string role) =>
 ValidateHelper.IsPlumpList(loginuser.Roles) && loginuser.Roles.Contains(role);
Esempio n. 5
0
 public static string UserNameOrNickName(this LoginUserInfo loginuser) =>
 loginuser.NickName ?? loginuser.UserName;