Removes the largest batch of React-19-blocking warnings: the 0.31 components (Grid, FormGroup, ControlLabel, Navbar.Header/Brand, Checkbox, SafeAnchor) all leaned on legacy context / defaultProps. 29 files converted: Grid->Container, FormGroup/ControlLabel/FormControl/ HelpBlock -> Form.Group/Label/Control/Text, Checkbox -> Form.Check (label as prop), bsStyle->variant (default->secondary), bsSize->size, pull-right->float-end. Custom Col.js now re-exports v2's Col; custom NavItem.js rewritten self-contained (no SafeAnchor/createChainedFunction); Navigation.js drops react-bootstrap Navbar (raw markup anyway). CSS stays on Bootstrap 4 (alexwine:bootstrap-4) for now: the BS4->5 jump is entangled with the jQuery carousel/swipe + navbar-collapse and is tracked as separate debt in UPGRADE.md. Only .form-label needed a shim (forms.scss). Browser-verified home carousel+navbar, signup form + terms checkbox, login form; REST smoke byte-identical.
107 lines
3.5 KiB
JavaScript
107 lines
3.5 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { Row, Alert, Form, Button } from 'react-bootstrap';
|
|
import Col from '../../components/Col/Col';
|
|
import { Accounts } from 'meteor/accounts-base';
|
|
import { Bert } from 'meteor/themeteorchef:bert';
|
|
import { Helmet } from 'react-helmet-async';
|
|
import validate from '../../../modules/validate';
|
|
import { withTranslation } from 'react-i18next';
|
|
import { T9n } from 'meteor-accounts-t9n';
|
|
|
|
class ResetPassword extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.t = props.t;
|
|
this.handleSubmit = this.handleSubmit.bind(this);
|
|
}
|
|
|
|
componentDidMount() {
|
|
const component = this;
|
|
|
|
validate(component.form, {
|
|
rules: {
|
|
newPassword: {
|
|
required: true,
|
|
minlength: 6,
|
|
},
|
|
repeatNewPassword: {
|
|
required: true,
|
|
minlength: 6,
|
|
equalTo: '[name="newPassword"]',
|
|
},
|
|
},
|
|
messages: {
|
|
newPassword: {
|
|
required: this.t("Introduce una nueva contraseña, por favor."),
|
|
minlength: this.t("Usa al menos seis caracteres."),
|
|
},
|
|
repeatNewPassword: {
|
|
required: this.t("Repite tu nueva contraseña, por favor."),
|
|
equalTo: this.t("Mmmm, tus contraseñas no coinciden. ¿Inténtalo otra vez?"),
|
|
minlength: this.t("Usa al menos seis caracteres."),
|
|
},
|
|
},
|
|
submitHandler() { component.handleSubmit(); },
|
|
});
|
|
}
|
|
|
|
handleSubmit() {
|
|
const { match, history } = this.props;
|
|
const token = match.params.token;
|
|
|
|
Accounts.resetPassword(token, this.newPassword.value, (error) => {
|
|
if (error) {
|
|
Bert.alert(T9n.get(`error.accounts.${error.reason}`), 'danger');
|
|
} else {
|
|
history.push('/subscriptions');
|
|
}
|
|
});
|
|
}
|
|
|
|
render() {
|
|
return (<div className="ResetPassword">
|
|
<Row className="align-items-center justify-content-center">
|
|
<Helmet>
|
|
<title>{this.t('AppName')}: {this.t('Resetea tu contraseña')}</title>
|
|
</Helmet>
|
|
<Col xs={12} sm={6} md={4}>
|
|
<h4 className="page-header">{this.t("Resetea tu contraseña")}</h4>
|
|
<Alert variant="info">
|
|
{ this.t("Para resetear tu contraseña, introduce una nueva debajo. Iniciarás la sesión con la nueva contraseña.") }
|
|
</Alert>
|
|
<form ref={form => (this.form = form)} onSubmit={event => event.preventDefault()}>
|
|
<Form.Group>
|
|
<Form.Label>{this.t("Nueva contraseña")}</Form.Label>
|
|
<input
|
|
type="password"
|
|
className="form-control"
|
|
ref={newPassword => (this.newPassword = newPassword)}
|
|
name="newPassword"
|
|
placeholder={this.t("Nueva contraseña")}
|
|
/>
|
|
</Form.Group>
|
|
<Form.Group>
|
|
<Form.Label>{this.t("Repite la nueva contraseña")}</Form.Label>
|
|
<input
|
|
type="password"
|
|
className="form-control"
|
|
ref={repeatNewPassword => (this.repeatNewPassword = repeatNewPassword)}
|
|
name="repeatNewPassword"
|
|
placeholder={this.t("Repite la nueva contraseña")}
|
|
/>
|
|
</Form.Group>
|
|
<Button type="submit" variant="success">{this.t("Resetea la contraseña y entra")}</Button>
|
|
</form>
|
|
</Col>
|
|
</Row>
|
|
</div>);
|
|
}
|
|
}
|
|
|
|
ResetPassword.propTypes = {
|
|
match: PropTypes.object.isRequired,
|
|
history: PropTypes.object.isRequired,
|
|
};
|
|
|
|
export default withTranslation()(ResetPassword);
|