source: imaps-frontend/src/pages/AuthCallback.jsx@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 664 bytes
RevLine 
[79a0317]1import {useEffect} from "react";
2import {useLocation, useNavigate} from "react-router-dom";
3import {useAppContext} from "../components/AppContext/AppContext.jsx";
4
5export function AuthCallback(){
6 const location = useLocation();
7 const navigate = useNavigate();
8 const {setUsername,setIsAuthenticated} = useAppContext()
9 useEffect(() => {
10 const searchParams = new URLSearchParams(location.search);
11 const token = searchParams.get('token');
12 const username = searchParams.get('username');
13 localStorage.setItem("token",token)
14 setIsAuthenticated(true)
15 setUsername(username)
16 navigate("/")
17 }, []);
18}
Note: See TracBrowser for help on using the repository browser.