mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
WIP / Design login and register page.
This commit is contained in:
@@ -4,34 +4,49 @@ import t from 'store/types';
|
||||
export default function login({ form }) {
|
||||
return (dispatch) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
ApiService.post('auth/login', form).then(response => {
|
||||
const { data } = response;
|
||||
ApiService.post('auth/login', form)
|
||||
.then((response) => {
|
||||
const { data } = response;
|
||||
|
||||
dispatch({ type: t.LOGIN_CLEAR_ERRORS });
|
||||
if (data.token && data.user) {
|
||||
dispatch({
|
||||
type: t.LOGIN_SUCCESS,
|
||||
payload: {
|
||||
user: data.user,
|
||||
token: data.token,
|
||||
},
|
||||
});
|
||||
}
|
||||
resolve(response);
|
||||
}).catch((error) => {
|
||||
const { response } = error;
|
||||
const { data } = response;
|
||||
const { errors } = data;
|
||||
dispatch({ type: t.LOGIN_CLEAR_ERRORS });
|
||||
if (data.token && data.user) {
|
||||
dispatch({
|
||||
type: t.LOGIN_SUCCESS,
|
||||
payload: {
|
||||
user: data.user,
|
||||
token: data.token,
|
||||
},
|
||||
});
|
||||
}
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
const { response } = error;
|
||||
const { data } = response;
|
||||
const { errors } = data;
|
||||
|
||||
dispatch({type: t.LOGIN_CLEAR_ERRORS});
|
||||
dispatch({ type: t.LOGIN_CLEAR_ERRORS });
|
||||
|
||||
if (errors){
|
||||
dispatch({
|
||||
type: t.LOGIN_FAILURE, errors,
|
||||
});
|
||||
}
|
||||
reject(error);
|
||||
});
|
||||
if (errors) {
|
||||
dispatch({
|
||||
type: t.LOGIN_FAILURE,
|
||||
errors,
|
||||
});
|
||||
}
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const submitResetPassword = (password) => {
|
||||
return (dispatch) => {
|
||||
return ApiService.post('auth/reset_password', password);
|
||||
};
|
||||
};
|
||||
|
||||
export const submitSendResetPassword = (email) => {
|
||||
return (dispatch) => {
|
||||
return ApiService.post('auth/send_reset_password', email);
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user