From 07c457a31c132667a35e7c28f1d7e5af497f4904 Mon Sep 17 00:00:00 2001 From: muerwre Date: Mon, 10 Dec 2018 14:36:26 +0700 Subject: [PATCH] auth: added backend debugging x5 --- src/redux/user/sagas.js | 17 +++++++++++------ src/utils/api.js | 18 +++++++++++++++--- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/redux/user/sagas.js b/src/redux/user/sagas.js index 2899cef..9b15044 100644 --- a/src/redux/user/sagas.js +++ b/src/redux/user/sagas.js @@ -1,7 +1,7 @@ import { REHYDRATE } from 'redux-persist'; import { delay } from 'redux-saga'; import { takeLatest, select, call, put, takeEvery, race, take } from 'redux-saga/effects'; -import { checkUserToken, getGuestToken, getStoredMap, getVkIframeUser, postMap } from '$utils/api'; +import { checkUserToken, getGuestToken, getStoredMap, getVkIframeUser, getVkUserInfo, postMap } from '$utils/api'; import { hideRenderer, iframeLoginVk, setActiveSticker, setAddress, @@ -102,13 +102,16 @@ function* loadMapSaga(path) { return map; } -function* vkIframeAuth({ viewer_id, access_token, auth_key }) { - // const user = yield call(getVkIframeUser, { viewer_id, access_token }); - // +function* iframeLoginVkSaga({ viewer_id: user_id, access_token, auth_key }) { + const data = yield call(getVkUserInfo, { user_id, access_token }); + + console.log('PARAMS', { user_id, access_token, auth_key }); + + if (data) console.log('GOT DATA!', data); // if (user) return yield put(setUser(user)); - // + // return null; - return yield console.log('GOT', { viewer_id, access_token, auth_key }); + return; } function* mapInitSaga() { @@ -449,4 +452,6 @@ export function* userSaga() { yield takeLatest(ACTIONS.GOT_VK_USER, gotVkUserSaga); yield takeLatest(ACTIONS.KEY_PRESSED, keyPressedSaga); + + yield takeLatest(ACTIONS.IFRAME_LOGIN_VK, iframeLoginVkSaga); } diff --git a/src/utils/api.js b/src/utils/api.js index 624c819..304fd64 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -32,7 +32,19 @@ export const postMap = ({ logo, distance, }).then(result => (result && result.data && result.data)).catch(() => null); +// +// export const getVkIframeUser = ({ viewer_id: user_id, access_token }) => (axios.get(API.VK_IFRAME_AUTH, { +// params: { user_id, access_token } +// }).then(result => (result && result.data))).catch(() => null); -export const getVkIframeUser = ({ viewer_id: user_id, access_token }) => (axios.get(API.VK_IFRAME_AUTH, { - params: { user_id, access_token } -}).then(result => (result && result.data))).catch(() => null); +export const getVkUserInfo = ({ user_id, access_token }) => (axios.get( + 'http://api.vk.com/method/users.get', + { + params: { + user_id, + fields: 'photo', + v: '5.67', + access_token, + } + } +));