Commit 6cecf9fb authored by Matija Obreza's avatar Matija Obreza

Fix: Handle invalid CLIENT_ID and SECRET

- Prevents infinite loop
parent 3d1dc1a2
......@@ -23,7 +23,7 @@ const i18nServer = i18n
order: ['path'],
lookupFromPathIndex: 0,
},
...optionsBase
...optionsBase,
});
export default i18nServer;
......@@ -22,10 +22,14 @@
"build": "webpack --config config/webpack-development.config.js",
"build:production": "cross-env NODE_ENV=production SSR=true webpack --config config/webpack-production.config.js",
"build:server": "cross-env NODE_ENV=production SSR=true webpack --config config/server.config.js",
"build:serverdebug": "cross-env SSR=true webpack --config config/server.config.js",
"serve": "webpack-dev-server --config config/webpack-development.config.js",
"serve:production": "cross-env NODE_ENV=production webpack-dev-server --config config/webpack-production.config.js",
"build:ssr": "rimraf target && npm run build:production && npm run build:server",
"serve:ssr": "npm run build:ssr && cd target/app/server && cross-env SSR=true node server.js",
"build:ssrdebug": "rimraf target && npm run build && npm run build:serverdebug",
"debug:ssr": "npm run build:ssrdebug && cd target/app/server && cross-env SSR=true node server.js",
"ssr": "cd target/app/server && cross-env SSR=true node server.js",
"i18nscan": "i18next-scanner --config i18next-scanner.config.js 'src/**/*.tsx'"
},
"dependencies": {
......
import { checkTokenRequest, loginAppRequest, loginUser } from 'actions/login';
import ApiError from 'model/ApiError';
function checkAuthTokenRequest(req, dispatch) {
const token = req.cookies.access_token;
......@@ -9,12 +10,12 @@ function checkAuthTokenRequest(req, dispatch) {
console.log(`User token ${token} is valid, response`, checkedToken);
return dispatch(loginUser(checkedToken));
})
.catch(() => {
console.log('Server: check failed dispatching loginAppRequest');
.catch((err) => {
console.log('Cookie check failed, dispatching loginAppRequest', ApiError.axiosError(err));
return dispatch(loginAppRequest());
});
} else {
console.log('Server: No token in cookie, dispatching loginAppRequest');
console.log('No token in cookie, dispatching loginAppRequest');
return dispatch(loginAppRequest());
}
}
......@@ -31,9 +32,10 @@ export default function checkAuthToken(req, res, dispatch) {
res.clearCookie('authorities');
}
return data;
}).catch((x) => {
console.log('Failed checkAuthToken, clearing cookies', x);
}).catch((err) => {
console.log('Failed checkAuthToken, clearing cookies', ApiError.axiosError(err));
res.clearCookie('access_token');
res.clearCookie('authorities');
return Promise.reject({ message: 'Could not authenticate against the API.' });
});
}
......@@ -14,7 +14,7 @@ export default function fetchComponentData(dispatch, branch, search) {
}).forEach((promise) => {
console.log(`Component ${component} needs`, promise);
// a nice array of Promises
promisesWithProps.push(promise)
promisesWithProps.push(promise);
});
});
......
......@@ -139,6 +139,9 @@ const prerenderer = (html) => (req, res) => {
console.error('Error:', err);
res.status(500).end(err.message);
});
}).catch((err) => {
console.error('Error:', err);
res.status(500).end(err.message);
});
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment