todos-contra-el-fuego-web/imports/ui/pages/VerifyEmail/VerifyEmail.js
cleverbeagle 75b470907b - Add support for email verification.
- Clean up formatting of accounts email templates.
2017-08-01 10:11:58 -05:00

42 lines
1.1 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { Alert } from 'react-bootstrap';
import { Accounts } from 'meteor/accounts-base';
import { Bert } from 'meteor/themeteorchef:bert';
class VerifyEmail extends React.Component {
constructor(props) {
super(props);
this.state = { error: null };
}
componentDidMount() {
const { match, history } = this.props;
Accounts.verifyEmail(match.params.token, (error) => {
if (error) {
Bert.alert(error.reason, 'danger');
this.setState({ error: `${error.reason}. Please try again.` });
} else {
setTimeout(() => {
Bert.alert('All set, thanks!', 'success');
history.push('/documents');
}, 2000);
}
});
}
render() {
return (<div className="VerifyEmail">
<Alert bsStyle={!this.state.error ? 'info' : 'danger'}>
{!this.state.error ? 'Verifying...' : this.state.error}
</Alert>
</div>);
}
}
VerifyEmail.propTypes = {
match: PropTypes.object.isRequired,
history: PropTypes.object.isRequired,
};
export default VerifyEmail;