diff --git a/src/components/login/CaptchaForm.js b/src/components/login/CaptchaForm.js deleted file mode 100644 index 0bbf9488..00000000 --- a/src/components/login/CaptchaForm.js +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright 2015 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -'use strict'; - -var React = require('react'); -var sdk = require('matrix-react-sdk') - -var DIV_ID = 'mx_recaptcha'; - -/** - * A pure UI component which displays a captcha form. - */ -module.exports = React.createClass({ - displayName: 'CaptchaForm', - - propTypes: { - onCaptchaLoaded: React.PropTypes.func.isRequired // called with div id name - }, - - getDefaultProps: function() { - return { - onCaptchaLoaded: function() { - console.error("Unhandled onCaptchaLoaded"); - } - }; - }, - - componentDidMount: function() { - // Just putting a script tag into the returned jsx doesn't work, annoyingly, - // so we do this instead. - var self = this; - if (this.refs.recaptchaContainer) { - console.log("Loading recaptcha script..."); - var scriptTag = document.createElement('script'); - window.mx_on_recaptcha_loaded = function() { - console.log("Loaded recaptcha script."); - self.props.onCaptchaLoaded(DIV_ID); - }; - scriptTag.setAttribute( - 'src', global.location.protocol+"//www.google.com/recaptcha/api.js?onload=mx_on_recaptcha_loaded&render=explicit" - ); - this.refs.recaptchaContainer.appendChild(scriptTag); - } - }, - - render: function() { - // FIXME: Tight coupling with the div id and SignupStages.js - return ( -
- This Home Server would like to make sure you are not a robot -
-
- ); - } -}); \ No newline at end of file diff --git a/src/components/login/Registration.js b/src/components/login/Registration.js index c721b005..f7a9be36 100644 --- a/src/components/login/Registration.js +++ b/src/components/login/Registration.js @@ -23,7 +23,7 @@ var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); var dis = require('matrix-react-sdk/lib/dispatcher'); var ServerConfig = require("./ServerConfig"); var RegistrationForm = require("./RegistrationForm"); -var CaptchaForm = require("./CaptchaForm"); +var CaptchaForm = require("matrix-react-sdk/lib/components/login/CaptchaForm"); var Signup = require("matrix-react-sdk/lib/Signup"); var MIN_PASSWORD_LENGTH = 6; diff --git a/src/controllers/templates/Register.js b/src/controllers/templates/Register.js deleted file mode 100644 index 5f88d590..00000000 --- a/src/controllers/templates/Register.js +++ /dev/null @@ -1,58 +0,0 @@ -/* -Copyright 2015 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -'use strict'; - -var extend = require('matrix-react-sdk/lib/extend'); -var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); -var BaseRegisterController = require('matrix-react-sdk/lib/controllers/templates/Register.js'); - -var RegisterController = {}; -extend(RegisterController, BaseRegisterController); - -RegisterController.onRegistered = function(user_id, access_token) { - MatrixClientPeg.replaceUsingAccessToken( - this.state.hs_url, this.state.is_url, user_id, access_token - ); - - this.setState({ - step: 'profile', - busy: true - }); - - var self = this; - var cli = MatrixClientPeg.get(); - cli.getProfileInfo(cli.credentials.userId).done(function(result) { - self.setState({ - avatarUrl: result.avatar_url, - busy: false - }); - }, - function(err) { - console.err(err); - self.setState({ - busy: false - }); - }); -}; - -RegisterController.onAccountReady = function() { - if (this.props.onLoggedIn) { - this.props.onLoggedIn(); - } -}; - -module.exports = RegisterController; diff --git a/src/skins/vector/skindex.js b/src/skins/vector/skindex.js index 45d60f73..a2b8d8cd 100644 --- a/src/skins/vector/skindex.js +++ b/src/skins/vector/skindex.js @@ -85,6 +85,5 @@ skin['organisms.UserSettings'] = require('./views/organisms/UserSettings'); skin['organisms.ViewSource'] = require('./views/organisms/ViewSource'); skin['pages.CompatibilityPage'] = require('./views/pages/CompatibilityPage'); skin['pages.MatrixChat'] = require('./views/pages/MatrixChat'); -skin['templates.Register'] = require('./views/templates/Register'); -module.exports = skin; \ No newline at end of file +module.exports = skin; diff --git a/src/skins/vector/views/templates/Register.js b/src/skins/vector/views/templates/Register.js deleted file mode 100644 index 8d6bbf42..00000000 --- a/src/skins/vector/views/templates/Register.js +++ /dev/null @@ -1,216 +0,0 @@ -/* -Copyright 2015 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -'use strict'; - -var React = require('react'); - -var sdk = require('matrix-react-sdk') -var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg') - -var RegisterController = require('../../../../controllers/templates/Register') -var ServerConfig = require("../../../../components/login/ServerConfig"); - -var config = require('../../../../../config.json'); - -module.exports = React.createClass({ - displayName: 'Register', - mixins: [RegisterController], - - getInitialState: function() { - // TODO: factor out all localstorage stuff into its own home. - // This is common to Login, Register and MatrixClientPeg - var localStorage = window.localStorage; - var hs_url, is_url; - if (localStorage) { - hs_url = localStorage.getItem("mx_hs_url"); - is_url = localStorage.getItem("mx_is_url"); - } - - // make sure we have our MatrixClient set up whatever - // Useful for debugging only. - // MatrixClientPeg.replaceUsingUrls( - // hs_url || config.default_hs_url, - // is_url || config.default_is_url - // ); - - return { - customHsUrl: hs_url || config.default_hs_url, - customIsUrl: is_url || config.default_is_url, - serverConfigVisible: (hs_url && hs_url !== config.default_hs_url || - is_url && is_url !== config.default_is_url) - } - }, - - getRegFormVals: function() { - return { - email: this.refs.email.value.trim(), - username: this.refs.username.value.trim(), - password: this.refs.password.value.trim(), - confirmPassword: this.refs.confirmPassword.value.trim() - }; - }, - - getHsUrl: function() { - if (this.state.serverConfigVisible) { - return this.state.customHsUrl; - } else { - return config.default_hs_url; - } - }, - - getIsUrl: function() { - if (this.state.serverConfigVisible) { - return this.state.customIsUrl; - } else { - return config.default_is_url; - } - }, - - onServerConfigVisibleChange: function(ev) { - this.setState({ - serverConfigVisible: ev.target.checked - }); - }, - - onServerUrlChanged: function(newUrl) { - this.setState({ - customHsUrl: this.refs.serverConfig.getHsUrl(), - customIsUrl: this.refs.serverConfig.getIsUrl(), - }); - this.forceUpdate(); - }, - - onProfileContinueClicked: function() { - this.onAccountReady(); - }, - - componentForStep: function(step) { - switch (step) { - case 'initial': - var serverConfigStyle = {}; - serverConfigStyle.display = this.state.serverConfigVisible ? 'block' : 'none'; - return ( -
-
-
-
-
-
- - - -
- -
-
- -
-
- ); - // XXX: clearly these should be separate organisms - case 'stage_m.login.email.identity': - return ( -
- Please check your email to continue registration. -
- ); - case 'stage_m.login.recaptcha': - return ( -
- This Home Server would like to make sure you are not a robot -
-
- ); - } - }, - - registerContent: function() { - if (this.state.busy) { - var Loader = sdk.getComponent("atoms.Spinner"); - return ( - - ); - } else if (this.state.step == 'profile') { - var ChangeDisplayName = sdk.getComponent('molecules.ChangeDisplayName'); - var ChangeAvatar = sdk.getComponent('molecules.ChangeAvatar'); - return ( -
- Set a display name: - - Upload an avatar: - - -
- ); - } else { - return ( -
-

Create an account

- {this.componentForStep(this.state.step)} -
{this.state.errorText}
- I already have an account -
- ); - } - }, - - onBadFields: function(bad) { - var keys = Object.keys(bad); - var strings = []; - for (var i = 0; i < keys.length; ++i) { - switch (bad[keys[i]]) { - case this.FieldErrors.PasswordMismatch: - strings.push("Passwords don't match"); - break; - case this.FieldErrors.Missing: - strings.push("Missing "+keys[i]); - break; - case this.FieldErrors.TooShort: - strings.push(keys[i]+" is too short"); - break; - case this.FieldErrors.InUse: - strings.push(keys[i]+" is already taken"); - break; - case this.FieldErrors.Length: - strings.push(keys[i] + " is not long enough."); - break; - default: - console.error("Unhandled FieldError: %s", bad[keys[i]]); - break; - } - } - var errtxt = strings.join(', '); - this.setState({ - errorText: errtxt - }); - }, - - render: function() { - return ( -
-
-
- vector -
- {this.registerContent()} -
-
- ); - } -});