IsInTree() public static method

public static IsInTree ( string targetPath, string rootPath ) : bool
targetPath string
rootPath string
return bool
Example #1
0
        /// <summary>
        /// If the whitelist contains the passed path, an <see cref="ApplicationException"/> will be thrown.
        /// WARNING: The protected paths are sensitive information.
        /// </summary>
        /// <param name="path">The examined path.</param>
        public static void AssertIsDeletable(string path)
        {
            if (Instance._protectedPaths.Contains(path, StringComparer.OrdinalIgnoreCase))
            {
                throw new ApplicationException("Protected content cannot be deleted or moved.");
            }

            if (AccessProvider.Current.GetOriginalUser() is Node user)
            {
                if (RepositoryPath.IsInTree(user.Path, path))
                {
                    throw new ApplicationException("Users cannot delete or move themselves.");
                }
            }
        }