fix: introduce fix for token management

This commit is contained in:
kasia.oczkowska
2024-04-04 14:16:25 +01:00
parent 0930c9d8d6
commit 526e093689
6 changed files with 18 additions and 29 deletions

View File

@@ -12,17 +12,20 @@ import { LOGIN } from 'graphql/mutations/login';
import Form from 'components/Form';
import TextField from 'components/TextField';
import useFormatMessage from 'hooks/useFormatMessage';
function LoginForm() {
const isCloud = useCloud();
const navigate = useNavigate();
const formatMessage = useFormatMessage();
const authentication = useAuthentication();
const [login, { loading }] = useMutation(LOGIN);
React.useEffect(() => {
if (authentication.isAuthenticated) {
navigate(URLS.DASHBOARD);
}
}, [authentication.isAuthenticated]);
const handleSubmit = async (values) => {
const { data } = await login({
variables: {
@@ -32,6 +35,7 @@ function LoginForm() {
const { token } = data.login;
authentication.updateToken(token);
};
return (
<Paper sx={{ px: 2, py: 4 }}>
<Typography
@@ -107,4 +111,5 @@ function LoginForm() {
</Paper>
);
}
export default LoginForm;