Skip to content

Commit

Permalink
fix: forget route when a user logs out explicit (Greenstand#658)
Browse files Browse the repository at this point in the history
* fix: forget route when a user logs out explicit

* fix: forget route when a user logs out explicit
  • Loading branch information
rishad190 authored May 29, 2022
1 parent f7e5be4 commit 7533e76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/components/Account.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { AppContext } from '../context/AppContext';
import axios from 'axios';
import { getDateTimeStringLocale } from '../common/locale';
import { documentTitle } from '../common/variables';
import { useHistory } from 'react-router-dom';

const style = (theme) => ({
accountContainer: {
Expand Down Expand Up @@ -81,8 +82,10 @@ function Account(props) {
const [newPassword, setNewPassword] = useState('');
const [confirmedPassword, setConfirmedPassword] = useState('');
const [errorMessage, setErrorMessage] = useState('');
const history = useHistory();

function handleLogout() {
history.push('/');
appContext.logout();
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const Login = (props) => {
{
userName,
password,
},
}
);
if (res.status === 200) {
const token = res.data.token;
Expand All @@ -153,7 +153,7 @@ const Login = (props) => {
setErrorMessage(e.response.data.errorMessage);
} else {
setErrorMessage(
'Could not log in. Please check your username and password or contact the admin.',
'Could not log in. Please check your username and password or contact the admin.'
);
}
setLoading(false);
Expand Down

0 comments on commit 7533e76

Please sign in to comment.