mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
cleaned up and fixed problem with open user opening pojrect
This commit is contained in:
parent
9355632f30
commit
51e69392a7
1 changed files with 18 additions and 12 deletions
|
@ -78,34 +78,40 @@ module.exports =
|
|||
timer.done()
|
||||
|
||||
|
||||
loadEditor: (req, res)->
|
||||
loadEditor: (req, res, next)->
|
||||
timer = new metrics.Timer("load-editor")
|
||||
if !Settings.editorIsOpen
|
||||
return res.render("general/closed", {title:"updating site"})
|
||||
|
||||
user_id = if req.session.user? then req.session.user._id else 'openUser'
|
||||
project_id = req.params.Project_id
|
||||
if req.session.user?
|
||||
user_id = req.session.user._id
|
||||
anonymous = false
|
||||
else
|
||||
anonymous = true
|
||||
user_id = 'openUser'
|
||||
|
||||
project_id = req.params.Project_id
|
||||
|
||||
async.parallel {
|
||||
project: (cb)->
|
||||
Project.findPopulatedById project_id, cb
|
||||
user: (cb)->
|
||||
User.findById user_id, cb
|
||||
if user_id == 'openUser'
|
||||
cb null, defaultSettingsForAnonymousUser(user_id)
|
||||
else
|
||||
User.findById user_id, cb
|
||||
subscription: (cb)->
|
||||
if user_id == 'openUser'
|
||||
return cb()
|
||||
SubscriptionLocator.getUsersSubscription user_id, cb
|
||||
}, (err, results)->
|
||||
if err?
|
||||
return res.send 500
|
||||
logger.err err:err, "error getting details for project page"
|
||||
return next err
|
||||
project = results.project
|
||||
user = results.user
|
||||
subscription = results.subscription
|
||||
|
||||
if user_id == 'openUser'
|
||||
anonymous = true
|
||||
user = defaultSettingsForAnonymousUser(user_id)
|
||||
else
|
||||
anonymous = false
|
||||
|
||||
SecurityManager.userCanAccessProject user, project, (canAccess, privilegeLevel)->
|
||||
if !canAccess
|
||||
return res.send 401
|
||||
|
@ -150,7 +156,7 @@ module.exports =
|
|||
timer.done()
|
||||
|
||||
|
||||
defaultSettingsForAnonymousUser = ->
|
||||
defaultSettingsForAnonymousUser = (user_id)->
|
||||
id : user_id
|
||||
ace:
|
||||
mode:'none'
|
||||
|
|
Loading…
Reference in a new issue