mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Intelligently redirect to v1 if no v2 project found for token
This commit is contained in:
parent
24c479e984
commit
e0ce988d32
2 changed files with 12 additions and 1 deletions
|
@ -3,9 +3,19 @@ AuthenticationController = require '../Authentication/AuthenticationController'
|
|||
TokenAccessHandler = require './TokenAccessHandler'
|
||||
Errors = require '../Errors/Errors'
|
||||
logger = require 'logger-sharelatex'
|
||||
settings = require 'settings-sharelatex'
|
||||
|
||||
module.exports = TokenAccessController =
|
||||
|
||||
redirectNotFoundErrorToV1: (err, req, res, next) ->
|
||||
if err instanceof Errors.NotFoundError and settings.overleaf
|
||||
logger.log {
|
||||
token: req.params['read_and_write_token']
|
||||
}, "[TokenAccess] No project found for token, redirecting to v1"
|
||||
res.redirect(settings.overleaf.host + req.url)
|
||||
else
|
||||
next(err)
|
||||
|
||||
_loadEditor: (projectId, req, res, next) ->
|
||||
req.params.Project_id = projectId.toString()
|
||||
return ProjectController.loadEditor(req, res, next)
|
||||
|
|
|
@ -426,6 +426,7 @@ module.exports = class Router
|
|||
maxRequests: 10,
|
||||
timeInterval: 60
|
||||
}),
|
||||
TokenAccessController.readAndWriteToken
|
||||
TokenAccessController.readAndWriteToken,
|
||||
TokenAccessController.redirectNotFoundErrorToV1
|
||||
|
||||
webRouter.get '*', ErrorController.notFound
|
||||
|
|
Loading…
Reference in a new issue