From b5772bd33de306fb3508e7549b0b94b2e7bc225d Mon Sep 17 00:00:00 2001 From: muerwre Date: Mon, 10 Dec 2018 14:32:23 +0700 Subject: [PATCH] auth: added backend debugging x4 --- src/redux/user/actions.js | 2 ++ src/redux/user/constants.js | 2 ++ src/redux/user/sagas.js | 21 ++++++++++++--------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/redux/user/actions.js b/src/redux/user/actions.js index d788c39..2a9e102 100644 --- a/src/redux/user/actions.js +++ b/src/redux/user/actions.js @@ -48,3 +48,5 @@ export const setReady = ready => ({ type: ACTIONS.SET_READY, ready }); export const gotVkUser = user => ({ type: ACTIONS.GOT_VK_USER, user }); export const keyPressed = ({ key }) => ({ type: ACTIONS.KEY_PRESSED, key }); + +export const iframeLoginVk = payload => ({ type: ACTIONS.IFRAME_LOGIN_VK, ...payload }); diff --git a/src/redux/user/constants.js b/src/redux/user/constants.js index a25340d..4a60ebf 100644 --- a/src/redux/user/constants.js +++ b/src/redux/user/constants.js @@ -48,4 +48,6 @@ export const ACTIONS = ({ GOT_VK_USER: 'GOT_VK_USER', KEY_PRESSED: 'KEY_PRESSED', + + IFRAME_LOGIN_VK: 'IFRAME_LOGIN_VK', }: { [key: String]: String }); diff --git a/src/redux/user/sagas.js b/src/redux/user/sagas.js index 0ed3f8a..2899cef 100644 --- a/src/redux/user/sagas.js +++ b/src/redux/user/sagas.js @@ -3,7 +3,7 @@ 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 { - hideRenderer, + hideRenderer, iframeLoginVk, setActiveSticker, setAddress, setChanged, setDialogActive, setEditing, @@ -102,21 +102,24 @@ function* loadMapSaga(path) { return map; } -function* vkIframeAuth({ viewer_id, access_token }) { - const user = yield call(getVkIframeUser, { viewer_id, access_token }); - - if (user) return yield put(setUser(user)); - - return null; +function* vkIframeAuth({ viewer_id, access_token, auth_key }) { + // const user = yield call(getVkIframeUser, { viewer_id, access_token }); + // + // if (user) return yield put(setUser(user)); + // + // return null; + return yield console.log('GOT', { viewer_id, access_token, auth_key }); } function* mapInitSaga() { const { hash } = getUrlData(); - const { viewer_id, access_token } = yield parseQuery(window.location.search); + const { viewer_id, access_token, auth_key } = yield parseQuery(window.location.search); + // const viewer_id = '360004'; // const access_token = '35baba3da5ac109775bc818f9f04d031ffeeb5a0f36afb42c3ab9a45035b04a12e7c70478c19dde07752b'; - if (viewer_id && access_token) yield call(vkIframeAuth, { viewer_id, access_token }); + // if (viewer_id && access_token) yield call(vkIframeAuth, { viewer_id, access_token }); + if (viewer_id && access_token) yield put(iframeLoginVk({ viewer_id, access_token, auth_key })); if (hash && /^#map/.test(hash)) { const [, newUrl] = hash.match(/^#map[:/?!](.*)$/);