Ajuste home redireciona para login caso token inválido
This commit is contained in:
@@ -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`)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user