Browse Source

removed cookies

feature/qrscanner
Nareshkumar Rao 3 years ago
parent
commit
77f0b3b753
  1. 4
      src/features/auth/authSlice.js
  2. 4
      src/screens/LoginScreen.js

4
src/features/auth/authSlice.js

@ -9,11 +9,13 @@ export const authSlice = createSlice({
name: 'auth',
initialState,
reducers: {
authLogin: (state, action) => {
authLogin: state => {
state.isAuthenticated = true;
Cookies.set('authorized', true);
},
authLogout: state => {
state.isAuthenticated = false;
Cookies.set('authorized', false);
},
},
});

4
src/screens/LoginScreen.js

@ -10,7 +10,7 @@ import axios from 'axios';
import { React, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Redirect, useHistory } from 'react-router-dom';
import { authLogin } from '../features/auth/authSlice';
import { authLogin, authLogout } from '../features/auth/authSlice';
function Login() {
const [email, setEmail] = useState(null);
@ -57,6 +57,7 @@ function Login() {
dispatch(authLogin());
history.push('/home');
} else {
dispatch(authLogout());
toast({
title: 'An error occurred',
description: response.data.message,
@ -67,6 +68,7 @@ function Login() {
}
})
.catch(err => {
dispatch(authLogout());
toast({
title: 'An error occurred',
description: 'Sorry, an error occurred on our side.',

Loading…
Cancel
Save