/// <summary> /// 使用cookie登录 /// </summary> public static void CookieLogin(this HttpContext context, LoginUserInfo loginuser) => context.RequestServices.Resolve_ <IAuthDataProvider>().SetToken(loginuser.LoginToken);
/// <summary> /// 判断用户是否有权限 /// </summary> public static bool HasPermission(this LoginUserInfo loginuser, string permission) => ValidateHelper.IsPlumpList(loginuser.Permissions) && loginuser.Permissions.Contains(permission);
/// <summary> /// 去除权限等敏感信息 /// </summary> public static void ClearPrivateInfo(this LoginUserInfo loginuser) { loginuser.Roles?.Clear(); loginuser.Permissions?.Clear(); }
/// <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);
public static string UserNameOrNickName(this LoginUserInfo loginuser) => loginuser.NickName ?? loginuser.UserName;