From 91c01597910191af2699d89fbb9e3a0d37650ba5 Mon Sep 17 00:00:00 2001 From: Sertac Poyraz Date: Sat, 29 Oct 2022 01:36:38 +0300 Subject: [PATCH] update auth context --- client/src/context/AuthContext.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/client/src/context/AuthContext.js b/client/src/context/AuthContext.js index 68f80d69e1..46c7238311 100644 --- a/client/src/context/AuthContext.js +++ b/client/src/context/AuthContext.js @@ -12,28 +12,24 @@ const AuthReducer = (state, action) => { switch (action.type) { case "LOGIN_START": return { - user: null, + ...state, loading: true, - error: null, }; case "LOGIN_SUCCESS": return { + ...state, user: action.payload, loading: false, - error: null, }; case "LOGIN_FAILURE": return { + ...state, user: null, loading: false, error: action.payload, }; case "LOGOUT": - return { - user: null, - loading: false, - error: null, - }; + return INITIAL_STATE; default: return state; }