mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
auth: api call?
This commit is contained in:
parent
088236c94e
commit
a43bac4c26
3 changed files with 21 additions and 2 deletions
|
@ -3,6 +3,7 @@ import { CLIENT } from '$config/frontend';
|
|||
export const API = {
|
||||
GET_GUEST: `${CLIENT.API_ADDR}/auth`,
|
||||
CHECK_TOKEN: `${CLIENT.API_ADDR}/auth`,
|
||||
IFRAME_LOGIN_VK: `${CLIENT.API_ADDR}/auth/iframe/vk`,
|
||||
GET_MAP: `${CLIENT.API_ADDR}/route`,
|
||||
POST_MAP: `${CLIENT.API_ADDR}/route`,
|
||||
};
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
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, getVkUserInfo, postMap } from '$utils/api';
|
||||
import {
|
||||
checkIframeToken,
|
||||
checkUserToken,
|
||||
getGuestToken,
|
||||
getStoredMap,
|
||||
getVkIframeUser,
|
||||
getVkUserInfo,
|
||||
postMap
|
||||
} from '$utils/api';
|
||||
import {
|
||||
hideRenderer, iframeLoginVk,
|
||||
setActiveSticker, setAddress,
|
||||
|
@ -146,7 +154,14 @@ function* authCheckSaga() {
|
|||
|
||||
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 (viewer_id && access_token && auth_key) {
|
||||
const user = yield call(checkIframeToken, { viewer_id, access_token, auth_key });
|
||||
|
||||
if (user) {
|
||||
yield put(setUser(user));
|
||||
return yield call(mapInitSaga);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (id && token) {
|
||||
|
|
|
@ -33,3 +33,6 @@ export const postMap = ({
|
|||
distance,
|
||||
}).then(result => (result && result.data && result.data));
|
||||
|
||||
export const checkIframeToken = ({ id, token }) => axios.get(API.IFRAME_LOGIN_VK, {
|
||||
params: { viewer_id, access_token, auth_key }
|
||||
}).then(result => (result && result.data));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue