Ajuste home redireciona para login caso token inválido

This commit is contained in:
Matheus Albino Brunhara
2022-09-03 16:07:36 -03:00
parent b3fd8946f5
commit 41fd7ea0b6

View File

@@ -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<LocationState>();
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`)
})
}