From 9e01a8d3c3daf3257f29ad63b3836dfa89c6200b Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 9 Feb 2024 19:10:01 +0300 Subject: vnext: authorize on backend --- vnext/src/App.js | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'vnext/src/App.js') diff --git a/vnext/src/App.js b/vnext/src/App.js index c7849418..f20d8db3 100644 --- a/vnext/src/App.js +++ b/vnext/src/App.js @@ -1,5 +1,5 @@ import { useState, useEffect, useRef, Fragment, useCallback } from 'react' -import { Route, Link, Routes, useSearchParams } from 'react-router-dom' +import { Route, Link, Routes } from 'react-router-dom' import svg4everybody from 'svg4everybody' @@ -12,11 +12,8 @@ import Chat from './ui/Chat' import Header from './ui/Header' import Post from './ui/Post' import Thread from './ui/Thread' -import Login from './ui/Login' -import { useCookies } from 'react-cookie' - -import { me, trends } from './api' +import { loginUrl, me, trends } from './api' import { useVisitor } from './ui/VisitorContext' import Avatar from './ui/Avatar' import { Toaster } from 'react-hot-toast' @@ -30,22 +27,20 @@ import { Toaster } from 'react-hot-toast' export default function App({ footer }) { let contentRef = useRef(null) - const [, setCookie] = useCookies(['hash']) const [allTrends, setAllTrends] = useState([]) const [visitor, setVisitor] = useVisitor() - const params = useSearchParams() - useEffect(() => { svg4everybody() + /* if (params['hash']) { setCookie('hash', params['hash'], { path: '/' }) let retpath = params['retpath'] || `${window.location.protocol}//${window.location.host}${window.location.pathname}` window.history.replaceState({}, document.title, retpath) - } - }, [setCookie, footer, params]) + }*/ + }, []) let updateStatus = useCallback(() => { // refresh server visitor state (unread counters) @@ -60,10 +55,9 @@ export default function App({ footer }) { let es if (visitor) { if ('EventSource' in window) { - const eventParams = new URLSearchParams({ hash: visitor.hash }) - let url = new URL(`https://juick.com/api/events?${eventParams.toString()}`) - console.log(url.toString()) - es = new EventSource(url.toString()) + es = new EventSource('/api/events', { + withCredentials: true + }) es.onopen = () => { console.log('online') } @@ -123,10 +117,10 @@ export default function App({ footer }) { Settings : - + Login - + } @@ -168,7 +162,6 @@ export default function App({ footer }) { } /> } /> } /> - } /> } /> } /> } /> -- cgit v1.2.3