mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
auth: getting viewer_id and access_token
This commit is contained in:
parent
e8a2e04562
commit
678f2b17a4
3 changed files with 17 additions and 3 deletions
|
@ -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';
|
||||||
|
@ -104,7 +104,9 @@ function* loadMapSaga(path) {
|
||||||
|
|
||||||
function* mapInitSaga() {
|
function* mapInitSaga() {
|
||||||
const { hash } = getUrlData();
|
const { hash } = getUrlData();
|
||||||
console.log('got credentials', window.location);
|
const { viewer_id, access_token } = yield parseQuery(window.location.search);
|
||||||
|
|
||||||
|
if (viewer_id && access_token) console.log('GOT THEM!', { viewer_id, access_token });
|
||||||
|
|
||||||
if (hash && /^#map/.test(hash)) {
|
if (hash && /^#map/.test(hash)) {
|
||||||
const [, newUrl] = hash.match(/^#map[:/?!](.*)$/);
|
const [, newUrl] = hash.match(/^#map[:/?!](.*)$/);
|
||||||
|
|
|
@ -8,5 +8,4 @@ export const toHours = (info) => {
|
||||||
return `${hrs}:${lmin}`;
|
return `${hrs}:${lmin}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const toTranslit = string => ru.reduce((text, el, i) => (text.replace(new RegExp(ru[i], 'g'), en[i])), (String(string) || ''));
|
export const toTranslit = string => ru.reduce((text, el, i) => (text.replace(new RegExp(ru[i], 'g'), en[i])), (String(string) || ''));
|
||||||
|
|
|
@ -13,3 +13,16 @@ export const getUrlData = (url = getPath()) => {
|
||||||
path, mode, host, hash
|
path, mode, host, hash
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Parses query string
|
||||||
|
export const parseQuery = (queryString: string) => {
|
||||||
|
let params = {};
|
||||||
|
const queries = decodeURIComponent(queryString)
|
||||||
|
.substring(queryString.substr(0, 1) === '?' ? 1 : 0)
|
||||||
|
.split('&');
|
||||||
|
for (let i = 0, l = queries.length; i < l; i += 1) {
|
||||||
|
const temp = queries[i].split('=');
|
||||||
|
params = { ...params, [temp[0]]: temp[1] };
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue