mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
auth: saga for logging through vk
This commit is contained in:
parent
a0c1f00be4
commit
2608b2687c
3 changed files with 16 additions and 1 deletions
|
@ -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 gotVkUser = user => ({ type: ACTIONS.GOT_VK_USER, user });
|
||||||
export const keyPressed = ({ key }) => ({ type: ACTIONS.KEY_PRESSED, key });
|
export const keyPressed = ({ key }) => ({ type: ACTIONS.KEY_PRESSED, key });
|
||||||
|
|
||||||
|
export const iframeLoginVk = payload => ({ type: ACTIONS.IFRAME_LOGIN_VK, ...payload });
|
||||||
|
|
|
@ -48,4 +48,6 @@ export const ACTIONS = ({
|
||||||
|
|
||||||
GOT_VK_USER: 'GOT_VK_USER',
|
GOT_VK_USER: 'GOT_VK_USER',
|
||||||
KEY_PRESSED: 'KEY_PRESSED',
|
KEY_PRESSED: 'KEY_PRESSED',
|
||||||
|
|
||||||
|
IFRAME_LOGIN_VK: 'IFRAME_LOGIN_VK',
|
||||||
}: { [key: String]: String });
|
}: { [key: String]: String });
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
setSaveOverwrite, setSaveSuccess, setTitle,
|
setSaveOverwrite, setSaveSuccess, setTitle,
|
||||||
setUser
|
setUser
|
||||||
} from '$redux/user/actions';
|
} from '$redux/user/actions';
|
||||||
import { getUrlData, pushPath } from '$utils/history';
|
import { getUrlData, parseQuery, pushPath } from '$utils/history';
|
||||||
import { editor } from '$modules/Editor';
|
import { editor } from '$modules/Editor';
|
||||||
import { ACTIONS } from '$redux/user/constants';
|
import { ACTIONS } from '$redux/user/constants';
|
||||||
import { MODES } from '$constants/modes';
|
import { MODES } from '$constants/modes';
|
||||||
|
@ -101,9 +101,18 @@ function* loadMapSaga(path) {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function* iframeLoginVkSaga({ viewer_id, access_token, auth_key }) {
|
||||||
|
return yield console.log('GOT', { viewer_id, access_token, auth_key });
|
||||||
|
}
|
||||||
|
|
||||||
function* mapInitSaga() {
|
function* mapInitSaga() {
|
||||||
const { hash } = getUrlData();
|
const { hash } = getUrlData();
|
||||||
|
|
||||||
|
if (window.location.search) {
|
||||||
|
const { viewer_id, access_token, auth_key } = yield parseQuery(window.location.search);
|
||||||
|
if (viewer_id && access_token && auth_key) yield put(iframeLoginVk({ viewer_id, access_token, auth_key }));
|
||||||
|
}
|
||||||
|
|
||||||
if (hash && /^#map/.test(hash)) {
|
if (hash && /^#map/.test(hash)) {
|
||||||
const [, newUrl] = hash.match(/^#map[:/?!](.*)$/);
|
const [, newUrl] = hash.match(/^#map[:/?!](.*)$/);
|
||||||
|
|
||||||
|
@ -421,4 +430,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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue