Commit 5359d0ad authored by Maxym Borodenko's avatar Maxym Borodenko Committed by Matija Obreza
Browse files

Updated UI part for new Google Sign-in authentication system

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