mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
fix auth error response and use 401 for malformed header
GitOrigin-RevId: 6dc4d10c25db7710b3e4e8e876d425a1e84574c8
This commit is contained in:
parent
dc06069dff
commit
c0ab195eed
1 changed files with 4 additions and 2 deletions
|
@ -194,10 +194,12 @@ module.exports = AuthenticationController =
|
|||
response = new Oauth2Server.Response(res)
|
||||
Oauth2Server.server.authenticate request, response, {}, (err, token) ->
|
||||
if err?
|
||||
# use a 401 status code for malformed header for git-bridge
|
||||
err.code = 401 if err.code == 400 and err.message == 'Invalid request: malformed authorization header'
|
||||
# fall back to v1 on invalid token
|
||||
return AuthenticationController._requireOauthV1Fallback req, res, next if err.code == 401
|
||||
# bubble up all other errors
|
||||
return next(err)
|
||||
# send all other errors
|
||||
return res.status(err.code).json({error: err.name, error_description: err.message})
|
||||
req.oauth =
|
||||
access_token: token.accessToken
|
||||
req.oauth_token = token
|
||||
|
|
Loading…
Reference in a new issue