mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #14565 from overleaf/jpa-add-error-context
[web] add response context to errors of failed logout/login action in CI GitOrigin-RevId: 9b2e23e243541f87476f8cc71687f9492f615b4d
This commit is contained in:
parent
6b61d906ba
commit
3d9e9f6aeb
1 changed files with 17 additions and 3 deletions
|
@ -142,7 +142,14 @@ class UserHelper {
|
|||
response.status !== 302 ||
|
||||
!response.headers.get('location').includes('/login')
|
||||
) {
|
||||
throw new Error('logout failed')
|
||||
const body = await response.text()
|
||||
throw new Error(
|
||||
`logout failed: status=${response.status} body=${JSON.stringify(
|
||||
body
|
||||
)} headers=${JSON.stringify(
|
||||
Object.fromEntries(response.headers.entries())
|
||||
)}`
|
||||
)
|
||||
}
|
||||
// after logout CSRF token becomes invalid
|
||||
this._csrfToken = ''
|
||||
|
@ -258,14 +265,21 @@ class UserHelper {
|
|||
}),
|
||||
})
|
||||
if (!response.ok) {
|
||||
const error = new Error('login failed')
|
||||
const body = await response.text()
|
||||
const error = new Error(
|
||||
`login failed: status=${response.status} body=${JSON.stringify(body)}`
|
||||
)
|
||||
error.response = response
|
||||
throw error
|
||||
}
|
||||
|
||||
const body = await response.json()
|
||||
if (body.redir !== '/project') {
|
||||
const error = new Error('login failed')
|
||||
const error = new Error(
|
||||
`login should redirect to /project: status=${
|
||||
response.status
|
||||
} body=${JSON.stringify(body)}`
|
||||
)
|
||||
error.response = response
|
||||
throw error
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue