mirror of
https://github.com/franjsco/tick3t
synced 2025-06-05 22:19:18 +02:00
feat: add change password api
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
import { config } from '../config';
|
import { config } from '../config';
|
||||||
|
import { authHeader } from '../_helpers';
|
||||||
|
|
||||||
|
|
||||||
export const userAPI = {
|
export const userAPI = {
|
||||||
login,
|
login,
|
||||||
logout,
|
logout,
|
||||||
|
changePassword,
|
||||||
};
|
};
|
||||||
|
|
||||||
function login(email, password) {
|
function login(email, password) {
|
||||||
@@ -45,3 +47,28 @@ function handleResponse(response) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function changePassword(user) {
|
||||||
|
const header = new Headers({
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'authorization': authHeader()
|
||||||
|
});
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
method: 'POST',
|
||||||
|
headers: header,
|
||||||
|
body: JSON.stringify({
|
||||||
|
newPassword: user.newPassword,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
return fetch(`${config.baseURL}users/changePassword`, options)
|
||||||
|
.then(res => {
|
||||||
|
if (res.ok) {
|
||||||
|
return res.json();
|
||||||
|
} else {
|
||||||
|
throw new Error('Ops,problem');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
Reference in New Issue
Block a user