mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
add custom error page for v1 project if no overleaf id
GitOrigin-RevId: 538c68c568c9138f26353d5492f4aa9d66fbae19
This commit is contained in:
parent
b3f590683d
commit
23ff7c23e8
4 changed files with 39 additions and 20 deletions
|
@ -281,13 +281,14 @@ module.exports = TokenAccessController = {
|
|||
if (userId == null) {
|
||||
return res.render('project/v2-import', { loginRedirect: redirectPath })
|
||||
} else {
|
||||
return TokenAccessHandler.getV1DocInfo(token, userId, function(
|
||||
err,
|
||||
doc_info
|
||||
) {
|
||||
TokenAccessHandler.getV1DocInfo(token, userId, function(err, doc_info) {
|
||||
if (err != null) {
|
||||
return next(err)
|
||||
}
|
||||
if (!doc_info) {
|
||||
res.status(400)
|
||||
return res.render('project/cannot-import-v1-project')
|
||||
}
|
||||
if (!doc_info.exists) {
|
||||
return next(new Errors.NotFoundError())
|
||||
}
|
||||
|
|
|
@ -141,10 +141,7 @@ const TokenAccessHandler = {
|
|||
},
|
||||
|
||||
findProjectWithHigherAccess(token, userId, callback) {
|
||||
TokenAccessHandler._getProjectByEitherToken(token, function(
|
||||
err,
|
||||
project
|
||||
) {
|
||||
TokenAccessHandler._getProjectByEitherToken(token, function(err, project) {
|
||||
if (err != null) {
|
||||
return callback(err)
|
||||
}
|
||||
|
@ -199,13 +196,15 @@ const TokenAccessHandler = {
|
|||
if (!req.session.anonTokenAccess) {
|
||||
req.session.anonTokenAccess = {}
|
||||
}
|
||||
req.session.anonTokenAccess[
|
||||
projectId.toString()
|
||||
] = token.toString()
|
||||
req.session.anonTokenAccess[projectId.toString()] = token.toString()
|
||||
},
|
||||
|
||||
getRequestToken(req, projectId) {
|
||||
const token = req.session && req.session.anonTokenAccess && req.session.anonTokenAccess[ projectId.toString() ] || req.headers['x-sl-anonymous-access-token']
|
||||
const token =
|
||||
(req.session &&
|
||||
req.session.anonTokenAccess &&
|
||||
req.session.anonTokenAccess[projectId.toString()]) ||
|
||||
req.headers['x-sl-anonymous-access-token']
|
||||
return token
|
||||
},
|
||||
|
||||
|
@ -282,6 +281,9 @@ const TokenAccessHandler = {
|
|||
return callback(err)
|
||||
}
|
||||
const v1UserId = user.overleaf != null ? user.overleaf.id : undefined
|
||||
if (!v1UserId) {
|
||||
return callback(null, null)
|
||||
}
|
||||
V1Api.request(
|
||||
{ url: `/api/v1/sharelatex/users/${v1UserId}/docs/${token}/info` },
|
||||
function(err, response, body) {
|
||||
|
|
18
services/web/app/views/project/cannot-import-v1-project.pug
Normal file
18
services/web/app/views/project/cannot-import-v1-project.pug
Normal file
|
@ -0,0 +1,18 @@
|
|||
extends ../layout
|
||||
|
||||
block content
|
||||
.content.content-alt
|
||||
.container
|
||||
.row
|
||||
.col-md-8.col-md-offset-2
|
||||
.card.project-invite-invalid
|
||||
.page-header.text-centered
|
||||
h1 Cannot Access Overleaf v1 Project
|
||||
.row.text-center
|
||||
.col-md-12
|
||||
p
|
||||
| The project you are attempting to access must be imported to Overleaf v2 before it can be accessed. Please contact the project owner or
|
||||
|
|
||||
a(href="/contact") contact support
|
||||
|
|
||||
| for assistance.
|
|
@ -855,27 +855,25 @@ describe('TokenAccess', function() {
|
|||
|
||||
after(() => delete settings.overleaf)
|
||||
|
||||
it('should redirect read and write token to v1', function(done) {
|
||||
it('should show error page for read and write token', function(done) {
|
||||
const unimportedV1Token = '123abc'
|
||||
return try_read_and_write_token_access(
|
||||
try_read_and_write_token_access(
|
||||
this.owner,
|
||||
unimportedV1Token,
|
||||
(response, body) => {
|
||||
expect(response.statusCode).to.equal(200)
|
||||
expect(body).to.contain('has not been imported to v2 yet.')
|
||||
expect(response.statusCode).to.equal(400)
|
||||
},
|
||||
done
|
||||
)
|
||||
})
|
||||
|
||||
it('should show import project page', function(done) {
|
||||
it('should show error page for read only token to v1', function(done) {
|
||||
const unimportedV1Token = 'abcd'
|
||||
return try_read_only_token_access(
|
||||
try_read_only_token_access(
|
||||
this.owner,
|
||||
unimportedV1Token,
|
||||
(response, body) => {
|
||||
expect(response.statusCode).to.equal(200)
|
||||
expect(body).to.contain('has not been imported to v2 yet.')
|
||||
expect(response.statusCode).to.equal(400)
|
||||
},
|
||||
done
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue