@bufferapp/session-manager
Advanced tools
Comparing version
@@ -8,2 +8,7 @@ const ObjectPath = require('object-path'); | ||
} = require('./urls'); | ||
const { | ||
cookieName, | ||
cookieDomain, | ||
destroyCookie, | ||
} = require('./cookies'); | ||
@@ -23,4 +28,25 @@ const setRequestSession = ({ | ||
next(); | ||
} catch (err) { | ||
next(err); | ||
} catch (e) { | ||
const bugsnag = req.app.get('bugsnag'); | ||
if (bugsnag) { | ||
bugsnag.notify(e, { | ||
originalUrl: req.originalUrl, | ||
}); | ||
} | ||
// destroy the cookie(s) and redirect to the login page | ||
// if getting the session failed for any reason | ||
destroyCookie({ | ||
name: cookieName({ production }), | ||
domain: cookieDomain({ production }), | ||
res, | ||
}); | ||
destroyCookie({ | ||
name: `${production ? '' : 'local'}bufferapp_ci_session`, | ||
domain: '.buffer.com', | ||
res, | ||
}); | ||
const redirect = encodeURIComponent(`https://${req.get('host')}${req.originalUrl}`); | ||
const baseUrl = | ||
`${loginServiceUrl({ production })}/login/`; | ||
res.redirect(`${baseUrl}?redirect=${redirect}`); | ||
} | ||
@@ -27,0 +53,0 @@ }; |
@@ -52,6 +52,13 @@ import RPCClient from 'micro-rpc-client'; | ||
}, | ||
app: { | ||
get: () => {}, | ||
}, | ||
get: () => {}, | ||
}; | ||
const sessionUrl = 'someSessionUrl'; | ||
const sessionKeys = ['*']; | ||
const res = {}; | ||
const res = { | ||
clearCookie: () => {}, | ||
redirect: () => {}, | ||
}; | ||
const next = jest.fn(); | ||
@@ -65,3 +72,3 @@ | ||
await configuredMiddlware(req, res, next); | ||
expect(next).toBeCalledWith(new Error(RPCClient.fakeErrorMessage)); | ||
expect(next).not.toBeCalled(); | ||
}); | ||
@@ -68,0 +75,0 @@ }); |
{ | ||
"name": "@bufferapp/session-manager", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"description": "Buffer session manager", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
27055
3.57%978
3.49%