78 lines
2.1 KiB
JavaScript
Executable File
78 lines
2.1 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 AuthenticationActionCreators from '../actions/AuthenticationActionCreators';
|
|
import AuthenticationStore from '../stores/AuthenticationStore';
|
|
import {Routes} from '../Constants';
|
|
import i18n from '../i18n';
|
|
import platform from 'platform';
|
|
|
|
const AuthorizeIPAddress = React.createClass({
|
|
mixins: [PureRenderMixin, Flux.StoreListenerMixin(AuthenticationStore)],
|
|
|
|
componentDidMount() {
|
|
process.nextTick(() => {
|
|
AuthenticationActionCreators.authorizeIPAddress(this.props.location.query['token']);
|
|
});
|
|
},
|
|
|
|
getStateFromStores() {
|
|
return {
|
|
verifyFailed: AuthenticationStore.didVerifyFail(),
|
|
verifySucceeded: AuthenticationStore.didVerifySucceed(),
|
|
};
|
|
},
|
|
|
|
renderLoginButton() {
|
|
if (platform.os.family === 'Android' || platform.os.family === 'iOS') {
|
|
return null;
|
|
}
|
|
return <Link to={Routes.LOGIN} className="btn btn-primary">{i18n.Messages.LOGIN}</Link>;
|
|
},
|
|
|
|
render() {
|
|
let content;
|
|
if (this.state.verifyFailed) {
|
|
content = (
|
|
<div>
|
|
<p className="error">{i18n.Messages.AUTHORIZATION_EXPIRED}</p>
|
|
<p className="error">{i18n.Messages.AUTHORIZATION_EXPIRED_SUGGESTION}</p>
|
|
{this.renderLoginButton()}
|
|
</div>
|
|
);
|
|
} else if (this.state.verifySucceeded) {
|
|
content = (
|
|
<div>
|
|
<h1>{i18n.Messages.IP_AUTHORIZATION_SUCCEEDED}</h1>
|
|
<p>{i18n.Messages.IP_AUTHORIZATION_SUCCEEDED_SUGGESTION}</p>
|
|
{this.renderLoginButton()}
|
|
</div>
|
|
);
|
|
} else {
|
|
content = (
|
|
<div>
|
|
<h1>{i18n.Messages.AUTHORIZING}</h1>
|
|
<Spinner />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<BaseAuthForm>
|
|
<div className="auth-verify">
|
|
{content}
|
|
</div>
|
|
</BaseAuthForm>
|
|
);
|
|
},
|
|
});
|
|
|
|
export default AuthorizeIPAddress;
|
|
|
|
|
|
|
|
// WEBPACK FOOTER //
|
|
// ./discord_app/components/AuthorizeIPAddress.js
|