2017-06-08_509bba0/509bba0_unpacked_with_node_modules/discord_app/components/VerifyEmail.js
2022-07-26 10:06:20 -07:00

75 lines
2 KiB
JavaScript
Executable file

import React from 'react';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import Flux from '../lib/flux';
import {Link} from 'react-router';
import BaseAuthForm from './BaseAuthForm';
import Spinner from './common/Spinner';
import Recaptcha from './common/Recaptcha';
import AuthenticationActionCreators from '../actions/AuthenticationActionCreators';
import AuthenticationStore from '../stores/AuthenticationStore';
import {Routes} from '../Constants';
import i18n from '../i18n';
const VerifyEmail = React.createClass({
mixins: [PureRenderMixin, Flux.StoreListenerMixin(AuthenticationStore)],
componentDidMount() {
process.nextTick(() => this.verify());
},
verify(captchaKey) {
AuthenticationActionCreators.verify(this.props.location.query['token'], captchaKey);
},
getStateFromStores() {
return {
verifyFailed: AuthenticationStore.didVerifyFail(),
verifyErrors: AuthenticationStore.getVerifyErrors(),
};
},
render() {
let content;
if (this.state.verifyErrors && this.state.verifyErrors['captcha_key']) {
content = (
<div className="auth-captcha">
<h1>{i18n.Messages.VERIFYING}</h1>
<div className="captcha-box">
<Recaptcha onChange={this.verify} theme="dark" />
</div>
</div>
);
} else if (this.state.verifyFailed) {
content = (
<div>
<p className="error">{i18n.Messages.VERFICATION_EXPIRED}</p>
<p className="error">{i18n.Messages.VERFICATION_EXPIRED_SUGGESTION}</p>
<Link to={Routes.LOGIN} className="btn btn-primary">{i18n.Messages.LOGIN}</Link>
</div>
);
} else {
content = (
<div>
<h1>{i18n.Messages.VERIFYING}</h1>
<Spinner />
</div>
);
}
return (
<BaseAuthForm>
<div className="auth-verify">
{content}
</div>
</BaseAuthForm>
);
},
});
export default VerifyEmail;
// WEBPACK FOOTER //
// ./discord_app/components/VerifyEmail.js