Commit e9439901 authored by Matija Obreza's avatar Matija Obreza
Browse files

Store API clientId in applicationConfig.clientId

- needed for Google auth
parent 8cfc2df1
......@@ -37,7 +37,7 @@ const prerenderer = (html, errHtml) => (req, res) => {
res.header('Access-Control-Allow-Headers', 'X-Requested-With');
const store = createStore(rootReducer, {} as any, applyMiddleware(thunk, routerMiddleware(createMemoryHistory)));
// Only send public data to client
store.dispatch(configure({ frontendPath: config.frontendPath, apiUrl: config.apiUrl, googleClientId: config.googleClientId }));
store.dispatch(configure({ frontendPath: config.frontendPath, apiUrl: config.apiUrl, googleClientId: config.googleClientId, clientId: config.clientId }));
console.log(`Processing request`, req._parsedOriginalUrl);
const pathname = req._parsedOriginalUrl.pathname;
......
......@@ -3,11 +3,13 @@ import {CONFIGURE_APPLICATION, SET_LANG} from 'constants/applicationConfig';
const INITIAL_STATE: {
clientId: string;
googleClientId: string;
apiUrl: string;
frontendPath: string;
lang: string,
} = {
clientId: process.env.CLIENT_ID || '',
googleClientId: process.env.GOOGLE_CLIENT_ID || '',
apiUrl: process.env.CATALOG_API_URL || 'http://localhost:8080',
frontendPath: '',
......
......@@ -62,9 +62,13 @@ export class LoginService {
});
}
public static verifyGoogleToken(googleClientId: string, tokenId) {
/**
* @param clientId our OAuth Client ID
* @param tokenId Token returned by Google Auth
*/
public static verifyGoogleToken(clientId: string, tokenId) {
const form = new FormData();
form.append('clientId', googleClientId);
form.append('clientId', clientId);
form.append('tokenId', tokenId);
return axiosBackend.post(VERIFY_GOOGLE_TOKEN_URL, form)
......
......@@ -62,8 +62,8 @@ export const verifyGoogleToken = (payload) => {
};
export const verifyGoogleTokenRequest = (tokenId) => (dispatch, getState) => {
const googleClientId = getState().applicationConfig.googleClientId;
return LoginService.verifyGoogleToken(googleClientId, tokenId)
const clientId = getState().applicationConfig.clientId;
return LoginService.verifyGoogleToken(clientId, tokenId)
.then((data) => {
saveCookies(data, data.exp * 1000 || new Date().getTime() + data.expires_in * 1000);
return dispatch(loginApp(data));
......
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