core-app-api: cookie auth review fixes
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
+1
-3
@@ -166,8 +166,6 @@ describe('startCookieAuthRefresh', () => {
|
||||
stop();
|
||||
});
|
||||
|
||||
expect(error).toEqual([
|
||||
'Session cookie refresh failed: Failed to get cookie again',
|
||||
]);
|
||||
expect(error).toEqual(['Session cookie refresh failed']);
|
||||
});
|
||||
});
|
||||
|
||||
+4
-4
@@ -55,7 +55,7 @@ export function startCookieAuthRefresh({
|
||||
try {
|
||||
const baseUrl = await discoveryApi.getBaseUrl(PLUGIN_ID);
|
||||
const requestUrl = `${baseUrl}/.backstage/auth/v1/cookie`;
|
||||
const res = await fetchApi.fetch(`${requestUrl}`, {
|
||||
const res = await fetchApi.fetch(requestUrl, {
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
@@ -65,8 +65,6 @@ export function startCookieAuthRefresh({
|
||||
);
|
||||
}
|
||||
|
||||
firstError = true;
|
||||
|
||||
const data = await res.json();
|
||||
if (!data.expiresAt) {
|
||||
throw new Error('No expiration date in response');
|
||||
@@ -77,6 +75,8 @@ export function startCookieAuthRefresh({
|
||||
throw new Error('Invalid expiration date in response');
|
||||
}
|
||||
|
||||
firstError = true;
|
||||
|
||||
channel?.postMessage({
|
||||
action: 'COOKIE_REFRESH_SUCCESS',
|
||||
payload: { expiresAt: new Date(expiresAt).toISOString() },
|
||||
@@ -94,7 +94,7 @@ export function startCookieAuthRefresh({
|
||||
errorBackoff * ERROR_BACKOFF_FACTOR,
|
||||
);
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`Session cookie refresh failed: ${error.message}`);
|
||||
console.error('Session cookie refresh failed', error);
|
||||
errorApi.post(
|
||||
new Error(
|
||||
`Session refresh failed, see developer console for details`,
|
||||
|
||||
Reference in New Issue
Block a user