Skip to content

Commit cfe5755

Browse files
committed
Implement password change request
1 parent 0a7d26c commit cfe5755

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/ChangePassword/changePassword.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,25 @@ export default function ChangePassword(props) {
88
const [newPassword, setNewPassword] = useState("");
99
const [confirmNewPassword, setConfirmNewPassword] = useState("");
1010

11+
const handleChangePasswordClick = e => {
12+
e.preventDefault();
13+
14+
fetch("https://api.bforborum.com/api/login", {
15+
method: "PUT",
16+
headers: {
17+
"content-type": "application/x-www-form-urlencoded",
18+
"authorization": "Basic " + sessionStorage.getItem("apiKey")
19+
},
20+
body: `password=${newPassword}`
21+
}).then(response => response.json()).then(response => {
22+
if (!response.ok) {
23+
alert("An error occurred and the password could not be changed.");
24+
}
25+
})
26+
};
27+
1128
return (
12-
<form className={changePassword.form}>
29+
<form onSubmit={handleChangePasswordClick} className={changePassword.form}>
1330
<FormField
1431
labelContent="Current Password"
1532
label="currpass"

0 commit comments

Comments
 (0)