From 41fd7ea0b6cca732b7bc26cb30235d88a5667267 Mon Sep 17 00:00:00 2001 From: Matheus Albino Brunhara Date: Sat, 3 Sep 2022 16:07:36 -0300 Subject: [PATCH] =?UTF-8?q?Ajuste=20home=20redireciona=20para=20login=20ca?= =?UTF-8?q?so=20token=20inv=C3=A1lido?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Home.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 465ab13..4915bd3 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -1,7 +1,7 @@ import { IonContent, IonPage, IonToast } from '@ionic/react'; import { Color } from '@ionic/core'; import { useContext, useEffect, useState } from 'react'; -import { useLocation } from 'react-router'; +import { useHistory, useLocation } from 'react-router'; import { UserContext } from '../App'; @@ -17,6 +17,7 @@ interface LocationState { const Home: React.FC = () => { const location = useLocation(); + const history = useHistory(); const user = useContext(UserContext); @@ -41,6 +42,7 @@ const Home: React.FC = () => { // setMessageToast(response.message); // setShowToast(true); + history.push(`/login`) return } @@ -52,6 +54,7 @@ const Home: React.FC = () => { // if (error.response.data.message) { console.dir('Houve um erro: ', { error }) alert('Houve um erro') + history.push(`/login`) }) }