diff --git a/src/components/user/actions.js b/src/components/user/actions.js index ad99a83..78d9ebc 100644 --- a/src/components/user/actions.js +++ b/src/components/user/actions.js @@ -1,4 +1,5 @@ import request from 'services/request'; +import accounts from 'services/api/accounts'; export const UPDATE = 'USER_UPDATE'; /** @@ -26,7 +27,7 @@ export function logout() { export function fetchUserData() { return (dispatch) => - request.get('/api/accounts/current') + accounts.current() .then((resp) => { dispatch(updateUser(resp)); }) @@ -51,8 +52,7 @@ export function changePassword({ logoutAll = true, }) { return (dispatch) => - request.post( - '/api/accounts/change-password', + accounts.changePassword( {password, newPassword, newRePassword, logoutAll} ) .then((resp) => { diff --git a/src/services/api/accounts.js b/src/services/api/accounts.js new file mode 100644 index 0000000..67eb43d --- /dev/null +++ b/src/services/api/accounts.js @@ -0,0 +1,19 @@ +import request from 'services/request'; + +export default { + current() { + return request.get('/api/accounts/current'); + }, + + changePassword({ + password = '', + newPassword = '', + newRePassword = '', + logoutAll = true + }) { + return request.post( + '/api/accounts/change-password', + {password, newPassword, newRePassword, logoutAll} + ); + } +};