/// <summary> /// 判断用户是否至少含有一个角色 /// </summary> /// <param name="user"></param> /// <param name="requiredRoleNames">待检测用户角色集合</param> /// <returns></returns> public static bool IsInRoles(this User user, params string[] requiredRoleNames) { if (user == null) { return(false); } RolesService rolesService = DIContainer.Resolve <RolesService>(); return(rolesService.IsUserInRoles(user.UserId, requiredRoleNames)); }
/// <summary> /// 判断用户是否是内容管理员 /// </summary> /// <param name="user"></param> /// <returns></returns> public static bool IsContentAdministrator(this User user) { RolesService roleService = DIContainer.Resolve <RolesService>(); return(roleService.IsUserInRoles(user.UserId, RoleNames.Instance().ContentAdministrator())); }