User Slice: Use API Instance instead of access token
This commit is contained in:
@@ -1,19 +1,19 @@
|
|||||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
||||||
import AuthToken from '../models/AuthToken';
|
import API from '../API';
|
||||||
|
|
||||||
export const userSlice = createSlice({
|
export const userSlice = createSlice({
|
||||||
name: 'user',
|
name: 'user',
|
||||||
initialState: {
|
initialState: {
|
||||||
token: undefined as AuthToken | undefined
|
apiAccess: undefined as API | undefined
|
||||||
},
|
},
|
||||||
reducers: {
|
reducers: {
|
||||||
setUserToken: (state, action: PayloadAction<AuthToken>) => {
|
setAPIAccess: (state, action: PayloadAction<API>) => {
|
||||||
state.token = action.payload;
|
state.apiAccess = action.payload;
|
||||||
},
|
},
|
||||||
unsetUserToken: (state) => {
|
unsetAPIAccess: (state) => {
|
||||||
state.token = undefined;
|
state.apiAccess = undefined;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
export const { setUserToken, unsetUserToken } = userSlice.actions;
|
export const { setAPIAccess, unsetAPIAccess } = userSlice.actions;
|
||||||
export default userSlice.reducer;
|
export default userSlice.reducer;
|
||||||
Reference in New Issue
Block a user