blob: 9e2632d5eeb5b60cf4349adf57f9f2a87c092b4c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import { createSlice } from "@reduxjs/toolkit";
const initialState = {
currentUser: null,
isAuthenticated: false,
};
export const authSlice = createSlice({
name: "auth",
initialState,
reducers: {
login: (state, action) => {
return { ...state, currentUser: action.payload, isAuthenticated: true };
},
logout: () => {
return initialState;
},
},
});
export const { login, logout } = authSlice.actions;
export default authSlice.reducer;
|