mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-16 05:03:02 +05:30
Decouple api/accounts into a separate module
This commit is contained in:
parent
428043f9a4
commit
6f54971a16
@ -1,4 +1,5 @@
|
|||||||
import request from 'services/request';
|
import request from 'services/request';
|
||||||
|
import accounts from 'services/api/accounts';
|
||||||
|
|
||||||
export const UPDATE = 'USER_UPDATE';
|
export const UPDATE = 'USER_UPDATE';
|
||||||
/**
|
/**
|
||||||
@ -26,7 +27,7 @@ export function logout() {
|
|||||||
|
|
||||||
export function fetchUserData() {
|
export function fetchUserData() {
|
||||||
return (dispatch) =>
|
return (dispatch) =>
|
||||||
request.get('/api/accounts/current')
|
accounts.current()
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
dispatch(updateUser(resp));
|
dispatch(updateUser(resp));
|
||||||
})
|
})
|
||||||
@ -51,8 +52,7 @@ export function changePassword({
|
|||||||
logoutAll = true,
|
logoutAll = true,
|
||||||
}) {
|
}) {
|
||||||
return (dispatch) =>
|
return (dispatch) =>
|
||||||
request.post(
|
accounts.changePassword(
|
||||||
'/api/accounts/change-password',
|
|
||||||
{password, newPassword, newRePassword, logoutAll}
|
{password, newPassword, newRePassword, logoutAll}
|
||||||
)
|
)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
|
19
src/services/api/accounts.js
Normal file
19
src/services/api/accounts.js
Normal file
@ -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}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user