From fe303999bb3d1067783ea96cef71ea2a4a69a2df Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 15 Dec 2018 23:21:02 +0100 Subject: embedding applets --- client/util.js | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) (limited to 'client/util.js') diff --git a/client/util.js b/client/util.js index 92b4addc..50d4992a 100644 --- a/client/util.js +++ b/client/util.js @@ -7,6 +7,7 @@ export const isMobile = isiPhone || isiPad || isAndroid export const isDesktop = !isMobile export const toArray = a => Array.prototype.slice.apply(a) +export const choice = a => a[Math.floor(Math.random() * a.length)] const htmlClassList = document.body.parentNode.classList htmlClassList.add(isDesktop ? 'desktop' : 'mobile') @@ -142,28 +143,3 @@ export const post = (uri, data, credentials) => { // headers['X-CSRFToken'] = csrftoken return fetch(uri, opt).then(res => res.json()) } - -// api queries -export const login = () => { - if (cachedAuth) return cachedAuth - const isLocal = (window.location.hostname === '0.0.0.0' || window.location.hostname === '127.0.0.1') - try { - const auth = JSON.parse(JSON.parse(localStorage.getItem('persist:root')).auth) - // console.log('auth', auth) - token = auth.token - username = auth.user.username - if (token) { - console.log('logged in', username) - } - cachedAuth = auth - if (!token && !isLocal) { - window.location.href = '/' - } - return auth - } catch (e) { - if (!isLocal) { - window.location.href = '/' - } - return {} - } -} -- cgit v1.2.3-70-g09d2