dual-salmonD
Refine3y ago
3 replies
dual-salmon

login

I have the Google Auth. I want to add the login using email and password and have implimented the following function in my login file. However, I don't know how to set the user to be authenticated si that it is not redirected to login page. How do I do that?

const handlelogin = (event: React.FormEvent) => { event.preventDefault(); axios.post('http://localhost:3001/login', { email: email, password: password } ).then((response) => { if (response.data.message) { alert(response.data.message); } else { console.log(response.data); localStorage.setItem('sessionToken', response.data.token); localStorage.setItem('isAuthenticated', 'true'); // Redirect the user to the dashboard navigate('/'); } }); };
Was this page helpful?