[HttpGet("{token}/{id}")]                       ///{currentWorkspace}")]
        public JsonResult GetPage(string token, int id) //, int currentWorkspace)
        {
            var page = _repo.GetPage(id);

            if (page == null)
            {
                throw new TedExeption(ExceptionCodes.PageNotFound);
            }

            if (!page.isPublic)
            {
                if (_auth.AuthenticateForWorkspace(token, page.WorkspaceId) == null)
                {
                    throw new TedExeption(ExceptionCodes.Authentication);
                }
            }

            // Load tree
            ICollection <Page> tree = null;

            //if (page.WorkspaceId!=currentWorkspace && !page.isPublic)
            if (!page.isPublic)
            {
                tree = _repo.GetNavigationTree(page.WorkspaceId);
            }
            // Avoid cyclic refs
            page.workspace.pages = null;
            return(Json(new
            {
                success = true,
                data = page,
                tree
            }));
        }
Exemple #2
0
        public JsonResult GetAllForWorkspace(string token, int workspaceId)
        {
            var user = _auth.AuthenticateForWorkspace(token, workspaceId);

            if (user == null)
            {
                throw new TedExeption(ExceptionCodes.Authentication);
            }

            return(Json(new
            {
                success = true,
                data = _repo.GetAllForWorkspace(workspaceId)
            }));
        }