auth: added login through vk iframe

This commit is contained in:
muerwre 2018-12-10 13:00:44 +07:00
parent 678f2b17a4
commit 9427866e60
5 changed files with 75 additions and 3 deletions

View file

@ -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, postMap } from '$utils/api';
import { checkUserToken, getGuestToken, getStoredMap, getVkIframeUser, postMap } from '$utils/api';
import {
hideRenderer,
setActiveSticker, setAddress,
@ -102,11 +102,19 @@ 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));
}
function* mapInitSaga() {
const { hash } = getUrlData();
const { viewer_id, access_token } = yield parseQuery(window.location.search);
// const viewer_id = '360004';
// const access_token = '35baba3da5ac109775bc818f9f04d031ffeeb5a0f36afb42c3ab9a45035b04a12e7c70478c19dde07752b';
if (viewer_id && access_token) console.log('GOT THEM!', { viewer_id, access_token });
if (viewer_id && access_token) yield call(vkIframeAuth, { viewer_id, access_token });
if (hash && /^#map/.test(hash)) {
const [, newUrl] = hash.match(/^#map[:/?!](.*)$/);