mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
WIP Frontend development.
This commit is contained in:
18
client/src/store/actions/auth.js
Normal file
18
client/src/store/actions/auth.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import ApiService from 'services/ApiService';
|
||||
import t from 'store/types';
|
||||
|
||||
export default function login({ form }) {
|
||||
return (dispatch) => {
|
||||
ApiService.post('/auth/login', form).then(response => {
|
||||
const { data } = response;
|
||||
|
||||
if (data.token && data.user) {
|
||||
dispatch({
|
||||
type: t.LOGIN_SUCCESS,
|
||||
user: data.user,
|
||||
token: data.token,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
0
client/src/store/actions/index.js
Normal file
0
client/src/store/actions/index.js
Normal file
@@ -12,7 +12,9 @@ export default function authentication(state = {}, action) {
|
||||
...state,
|
||||
token: '',
|
||||
};
|
||||
default:
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const isAuthenticated = (state) => !!state.token;
|
||||
@@ -1,6 +1,6 @@
|
||||
import { combineReducers } from 'redux';
|
||||
// import accounts from './accounts';
|
||||
import authentication from './authentication';
|
||||
// import accounts from './accounts';
|
||||
// import users from './users';
|
||||
|
||||
export default combineReducers({
|
||||
|
||||
Reference in New Issue
Block a user