use custom user endpoint for validation and JWT auth for login

This commit is contained in:
GotPPay
2018-08-28 14:35:37 +02:00
committed by Bilal Catic
parent 9da31990fd
commit bc61e2e706
3 changed files with 121 additions and 180 deletions

View File

@@ -29,36 +29,15 @@ export const recieveProfileInfo = (json) => ({
export const fetchProfileInfo = (idUser) => {
return dispatch => {
dispatch(requestProfileInfo());
dispatch(recieveProfileInfo({
"id": 2,
"name": "Customer User",
"mail": "customer@mail.com",
"phone": "",
"userType": "customer",
"vatCode": "556084-6783",
"companyName": "Coor Service Management AB",
"billingAddresses": [
{
"id": 1,
"city": "Göteborg",
"countryName": "SE",
"detailedAddress": "Lilla Bommen 2",
"firstName": "Customer",
"lastName": "User",
"zipCode": "12323"
return client.fetch({
url: `${API_SERVER}/wp-json/wc/v2/customers/${idUser}`,
method: 'get'
})
.then(response => {
if(response.data){
dispatch(recieveProfileInfo(response.data));
}
],
"profileAddresses": [
{
"id": 1,
"city": "Göteborg",
"countryName": "Göteborg",
"detailedAddress": "Lilla Bommen 2",
"zipCode": "12323"
}
]
}));
});
// return client.fetch({
// url: `${API_SERVER}/wp-json/wiaas/cart/customer-info`,
// method: 'get',
@@ -82,10 +61,14 @@ const requestSaveProfile = () => ({
export const saveProfileInfo = (idUser, profile) => {
return dispatch => {
dispatch(requestSaveProfile());
const parsedFullName = profile.name.trim().split(' ');
return client.fetch({
url: `${API_SERVER}/profileSettings/api/saveProfileInfo`,
method: 'post',
data: {idUser, profile: JSON.stringify(profile)}
url: `${API_SERVER}/wp-json/wc/v2/customers/${idUser}`,
method: 'put',
data: {
'first_name': parsedFullName[0],
'last_name': parsedFullName[1],
}
})
.then(response => {
if(response.data && response.data.messages){