mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Add endpoint to list entities within a project
This commit is contained in:
@@ -25,6 +25,7 @@ Sources = require "../Authorization/Sources"
|
||||
TokenAccessHandler = require '../TokenAccess/TokenAccessHandler'
|
||||
CollaboratorsHandler = require '../Collaborators/CollaboratorsHandler'
|
||||
Modules = require '../../infrastructure/Modules'
|
||||
ProjectEntityHandler = require './ProjectEntityHandler'
|
||||
crypto = require 'crypto'
|
||||
|
||||
module.exports = ProjectController =
|
||||
@@ -138,9 +139,8 @@ module.exports = ProjectController =
|
||||
return next(err) if err?
|
||||
res.sendStatus 200
|
||||
|
||||
projectsJson: (req, res, next) ->
|
||||
userProjectsJson: (req, res, next) ->
|
||||
user_id = AuthenticationController.getLoggedInUserId(req)
|
||||
|
||||
ProjectGetter.findAllUsersProjects user_id,
|
||||
'name lastUpdated publicAccesLevel archived owner_ref tokens', (err, projects) ->
|
||||
return next(err) if err?
|
||||
@@ -151,6 +151,24 @@ module.exports = ProjectController =
|
||||
|
||||
res.json({projects: projects})
|
||||
|
||||
projectEntitiesJson: (req, res, next) ->
|
||||
user_id = AuthenticationController.getLoggedInUserId(req)
|
||||
project_id = req.params.Project_id
|
||||
AuthorizationManager.canUserReadProject user_id, project_id,
|
||||
null, (err, canRead) ->
|
||||
return next(err) if err?
|
||||
return res.status(403) if !canRead
|
||||
ProjectGetter.getProject project_id, (err, project) ->
|
||||
return next(err) if err?
|
||||
ProjectEntityHandler.getAllEntitiesFromProject project, (err, docs, files) ->
|
||||
return next(err) if err?
|
||||
entities = docs.concat(files)
|
||||
.map (e) -> {
|
||||
path: e.path,
|
||||
type: if e.doc? then 'doc' else 'file'
|
||||
}
|
||||
res.json({entities: entities})
|
||||
|
||||
projectListPage: (req, res, next)->
|
||||
timer = new metrics.Timer("project-list")
|
||||
user_id = AuthenticationController.getLoggedInUserId(req)
|
||||
|
||||
Reference in New Issue
Block a user