auth: added backend debugging x5

This commit is contained in:
muerwre 2018-12-10 14:36:26 +07:00
parent b5772bd33d
commit 07c457a31c
2 changed files with 26 additions and 9 deletions

View file

@ -1,7 +1,7 @@
import { REHYDRATE } from 'redux-persist'; import { REHYDRATE } from 'redux-persist';
import { delay } from 'redux-saga'; import { delay } from 'redux-saga';
import { takeLatest, select, call, put, takeEvery, race, take } from 'redux-saga/effects'; 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 { import {
hideRenderer, iframeLoginVk, hideRenderer, iframeLoginVk,
setActiveSticker, setAddress, setActiveSticker, setAddress,
@ -102,13 +102,16 @@ function* loadMapSaga(path) {
return map; return map;
} }
function* vkIframeAuth({ viewer_id, access_token, auth_key }) { function* iframeLoginVkSaga({ viewer_id: user_id, access_token, auth_key }) {
// const user = yield call(getVkIframeUser, { viewer_id, access_token }); 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)); // if (user) return yield put(setUser(user));
//
// return null; // return null;
return yield console.log('GOT', { viewer_id, access_token, auth_key }); return;
} }
function* mapInitSaga() { function* mapInitSaga() {
@ -449,4 +452,6 @@ export function* userSaga() {
yield takeLatest(ACTIONS.GOT_VK_USER, gotVkUserSaga); yield takeLatest(ACTIONS.GOT_VK_USER, gotVkUserSaga);
yield takeLatest(ACTIONS.KEY_PRESSED, keyPressedSaga); yield takeLatest(ACTIONS.KEY_PRESSED, keyPressedSaga);
yield takeLatest(ACTIONS.IFRAME_LOGIN_VK, iframeLoginVkSaga);
} }

View file

@ -32,7 +32,19 @@ export const postMap = ({
logo, logo,
distance, distance,
}).then(result => (result && result.data && result.data)).catch(() => null); }).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, { export const getVkUserInfo = ({ user_id, access_token }) => (axios.get(
params: { user_id, access_token } 'http://api.vk.com/method/users.get',
}).then(result => (result && result.data))).catch(() => null); {
params: {
user_id,
fields: 'photo',
v: '5.67',
access_token,
}
}
));