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

Merge branch '395-google-sign-in-updated-ui' into 'master'

Updated UI part for new Google Sign-in authentication system

See merge request genesys-pgr/genesys-ui!166
parents b13dc3ab 5359d0ad
......@@ -62,14 +62,11 @@ export class LoginService {
});
}
public static verifyGoogleToken(token: string, accessToken) {
return axiosBackend.request({
url: VERIFY_GOOGLE_TOKEN_URL,
method: 'GET',
params: {
accessToken,
},
})
public static verifyGoogleToken(tokenId) {
const form = new FormData();
form.append('tokenId', tokenId);
return axiosBackend.post(VERIFY_GOOGLE_TOKEN_URL, form)
.then(({ data }) => data);
}
}
......@@ -61,10 +61,9 @@ export const verifyGoogleToken = (payload) => {
};
};
export const verifyGoogleTokenRequest = (accessToken) => (dispatch, getState) => {
const token = getState().login.access_token;
export const verifyGoogleTokenRequest = (tokenId) => (dispatch, getState) => {
return LoginService.verifyGoogleToken(token, accessToken)
return LoginService.verifyGoogleToken(tokenId)
.then((data) => {
saveCookies(data, data.exp * 1000 || new Date().getTime() + data.expires_in * 1000);
return dispatch(loginApp(data));
......
......@@ -49,7 +49,7 @@ class LoginContainer extends React.Component<ILoginContainerProps, void> {
private onGoogleLogin = (response): any => {
const { verifyGoogleTokenRequest, checkTokenRequest, history } = this.props;
log('Trying google login');
return verifyGoogleTokenRequest(response.accessToken)
return verifyGoogleTokenRequest(response.tokenId)
.then(({access_token}) => {
log('Access token', access_token);
return checkTokenRequest(access_token);
......
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