Skip to content
Snippets Groups Projects
Commit c3a75c95 authored by Quique's avatar Quique
Browse files

Ask for the old password in order to change it

parent 0e999271
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ class OwnPassword extends React.Component {
constructor(props) {
super(props);
this.state = {
oldPassword: "",
newPassword: "",
newPassword2: "",
formErrors: "",
......@@ -34,6 +35,8 @@ class OwnPassword extends React.Component {
this.setState(
{
error: null,
passwordChanged: null,
formErrors: formErrors,
isNewPasswordValid: isNewPasswordValid,
isNewPassword2Valid: isNewPassword2Valid,
......@@ -55,6 +58,7 @@ class OwnPassword extends React.Component {
this.setState({ isLoading: true, error: null });
const body = JSON.stringify({
old_password: this.state.oldPassword,
password: this.state.newPassword,
});
fetch("/api/member/me", {
......@@ -92,7 +96,7 @@ class OwnPassword extends React.Component {
if (this.state.error) {
alert = (
<Alert variant="danger">
Se produjo un error al intentar cambiar la contraseña:{" "}
Se produjo un error al intentar cambiar la contraseña:
{this.state.error}
</Alert>
);
......@@ -102,7 +106,6 @@ class OwnPassword extends React.Component {
alert = (
<Alert variant="success">La contraseña se ha cambiado con éxito.</Alert>
);
this.state.passwordChanged = false;
}
return (
......@@ -112,6 +115,21 @@ class OwnPassword extends React.Component {
{alert}
<Form onSubmit={this.handleSubmit}>
<Form.Group as={Row}>
<Form.Label as="legend" column sm={4}>
Contraseña actual
</Form.Label>
<Col sm={8}>
<Form.Control
placeholder="Contraseña actual"
type="password"
onChange={(e) =>
this.setState({ oldPassword: e.target.value })
}
/>
</Col>
</Form.Group>
<Form.Group as={Row}>
<Form.Label as="legend" column sm={4}>
Nueva contraseña
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment