WIP Frontend development.

This commit is contained in:
Ahmed Bouhuolia
2020-02-18 02:31:42 +02:00
parent e5c78fe555
commit a37341ff00
24 changed files with 364 additions and 80 deletions

View 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,
});
}
});
}
}

View File

View File

@@ -12,7 +12,9 @@ export default function authentication(state = {}, action) {
...state,
token: '',
};
default:
default:
return state;
}
}
}
export const isAuthenticated = (state) => !!state.token;

View File

@@ -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({