예제 #1
0
        // this action returns all folders and files that are contained in the needed folder
        public IActionResult Watch(string folderId)
        {
            // if the user is not authenticated, redirect to login page
            if (folderId == null && !User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Account"));
            }

            FolderVM folder = _fileSystemService.GetFolderById(folderId);
            string   userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            // check access to needed folder
            if (_fileSystemService.CheckAccessToView(folder, userId) || _fileSystemService.HasSharedChildren(folderId))
            {
                List <ElementVM>          elems      = _fileSystemService.GetElementsFromFolder(_fileSystemService.GetFolderById(folderId), userId).ToList();
                Stack <FolderShortInfoVM> folderPath = _fileSystemService.GetFolderPath(folderId, userId);

                WatchPageVM model = new WatchPageVM {
                    Elements = elems, FolderPath = folderPath, CurrFolderId = folderId
                };
                return(View(model));
            }
            else
            {
                throw new StatusCodeException($"You don't have access to folder with ID = {folderId}.", StatusCodes.Status403Forbidden);
            }
        }