Maintain token after browser refresh
This commit is contained in:
parent
fba62d4955
commit
52e04006df
@ -18,7 +18,7 @@ const existingToken = localStorage.getItem('token');
|
|||||||
// const existingUser = JSON.parse(localStorage.getItem('user'));
|
// const existingUser = JSON.parse(localStorage.getItem('user'));
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const [authToken, setAuthToken] = useState(existingToken);
|
const [authToken, setAuthToken] = useState(existingToken || '');
|
||||||
|
|
||||||
const setToken = (data) => {
|
const setToken = (data) => {
|
||||||
localStorage.setItem('token', JSON.stringify(data));
|
localStorage.setItem('token', JSON.stringify(data));
|
||||||
|
@ -1,14 +1,23 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Panel } from 'rsuite';
|
import { Panel } from 'rsuite';
|
||||||
|
|
||||||
|
import { useAuth } from '../helpers/authContext';
|
||||||
|
import NavBar from '../components/Navbar/NavBar';
|
||||||
|
|
||||||
const boxStyle = {
|
const boxStyle = {
|
||||||
margin: '50px 10px',
|
margin: '50px 10px',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Dashboard() {
|
export default function Dashboard() {
|
||||||
|
const { authToken } = useAuth();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
|
<NavBar title='Meeting Planner' />
|
||||||
<Panel header={<h3>Dashboard</h3>} bordered style={boxStyle}>
|
<Panel header={<h3>Dashboard</h3>} bordered style={boxStyle}>
|
||||||
<p>This is just experimenting with stuff.</p>
|
<p>This is just experimenting with stuff.</p>
|
||||||
|
<p>{authToken}</p>
|
||||||
</Panel>
|
</Panel>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Panel } from 'rsuite';
|
import { Panel } from 'rsuite';
|
||||||
|
|
||||||
|
import { useAuth } from '../helpers/authContext';
|
||||||
import NavBar from '../components/Navbar/NavBar';
|
import NavBar from '../components/Navbar/NavBar';
|
||||||
|
|
||||||
const boxStyle = {
|
const boxStyle = {
|
||||||
@ -8,11 +9,13 @@ const boxStyle = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
|
const { authToken } = useAuth();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<NavBar title='Meeting Planner' />
|
<NavBar title='Meeting Planner' />
|
||||||
<Panel header={<h3>Home</h3>} bordered style={boxStyle}>
|
<Panel header={<h3>Home</h3>} bordered style={boxStyle}>
|
||||||
<p>This will be the home page</p>
|
<p>This will be the home page</p>
|
||||||
|
<p>{authToken}</p>
|
||||||
</Panel>
|
</Panel>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user