diff --git a/skins/base/views/templates/Login.js b/skins/base/views/templates/Login.js
index ceae07ec41..49dd05f5fb 100644
--- a/skins/base/views/templates/Login.js
+++ b/skins/base/views/templates/Login.js
@@ -25,10 +25,37 @@ var Loader = require("react-loader");
var LoginController = require("../../../../src/controllers/templates/Login");
+var ServerConfig = ComponentBroker.get("molecules/ServerConfig");
+
module.exports = React.createClass({
displayName: 'Login',
mixins: [LoginController],
+ componentForStep: function(step) {
+ switch (step) {
+ case 'choose_hs':
+ return (
+
+ Please check your email to continue registration.
+
+ );
+ case 'stage_m.login.recaptcha':
+ return (
+
diff --git a/src/controllers/pages/MatrixChat.js b/src/controllers/pages/MatrixChat.js
index 44a4df0752..872a513117 100644
--- a/src/controllers/pages/MatrixChat.js
+++ b/src/controllers/pages/MatrixChat.js
@@ -179,7 +179,7 @@ module.exports = {
dis.dispatch({action: 'focus_composer'});
},
- showScreen(screen, params) {
+ showScreen: function(screen, params) {
if (screen == 'register') {
dis.dispatch({
action: 'start_registration',
diff --git a/src/controllers/templates/Login.js b/src/controllers/templates/Login.js
index 714fb2720a..1c05597080 100644
--- a/src/controllers/templates/Login.js
+++ b/src/controllers/templates/Login.js
@@ -24,8 +24,6 @@ var dis = require("../../dispatcher");
var ComponentBroker = require("../../ComponentBroker");
-var ServerConfig = ComponentBroker.get("molecules/ServerConfig");
-
module.exports = {
getInitialState: function() {
return {
@@ -100,31 +98,6 @@ module.exports = {
});
},
- componentForStep: function(step) {
- switch (step) {
- case 'choose_hs':
- return (
-
-
-
- );
- // XXX: clearly these should be separate organisms
- case 'stage_m.login.password':
- return (
-
-
-
- );
- }
- },
-
showRegister: function(ev) {
ev.preventDefault();
dis.dispatch({
diff --git a/src/controllers/templates/Register.js b/src/controllers/templates/Register.js
index 650fdd6b2d..4ad66d9f2b 100644
--- a/src/controllers/templates/Register.js
+++ b/src/controllers/templates/Register.js
@@ -24,9 +24,12 @@ var dis = require("../../dispatcher");
var ComponentBroker = require("../../ComponentBroker");
-var ServerConfig = ComponentBroker.get("molecules/ServerConfig");
-
module.exports = {
+ FieldErrors: {
+ PasswordMismatch: 'PasswordMismatch',
+ PasswordLength: 'PasswordLength'
+ },
+
getInitialState: function() {
return {
step: 'initial',
@@ -126,7 +129,7 @@ module.exports = {
if (
this.savedParams.email != '' ||
- this.completedStages.indexOf('m.login.email.identity' > -1)
+ this.completedStages.indexOf('m.login.email.identity') > -1
) {
return emailFlow;
} else {
@@ -156,22 +159,34 @@ module.exports = {
onInitialStageSubmit: function(ev) {
ev.preventDefault();
+
+ var formVals = this.getRegFormVals();
+
+ var badFields = {};
+ if (formVals.password != formVals.confirmPassword) {
+ badFields.confirmPassword = this.FieldErrors.PasswordMismatch;
+ }
+ if (formVals.password.length < 6) {
+ badFields.password = this.FieldErrors.PasswordLength;
+ }
+ this.onBadFields(badFields);
+
MatrixClientPeg.replaceUsingUrls(
- this.refs.serverConfig.getHsUrl(),
- this.refs.serverConfig.getIsUrl()
+ this.getHsUrl(),
+ this.getIsUrl()
);
this.setState({
- hs_url: this.refs.serverConfig.getHsUrl(),
- is_url: this.refs.serverConfig.getIsUrl()
+ hs_url: this.getHsUrl(),
+ is_url: this.getIsUrl()
});
var cli = MatrixClientPeg.get();
this.setState({busy: true});
var self = this;
this.savedParams = {
- email: this.refs.email.getDOMNode().value,
- username: this.refs.username.getDOMNode().value,
- password: this.refs.password.getDOMNode().value
+ email: formVals.email,
+ username: formVals.username,
+ password: formVals.password
};
this.tryRegister();
@@ -246,37 +261,6 @@ module.exports = {
}
},
- componentForStep: function(step) {
- switch (step) {
- case 'initial':
- 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're not a robot
-
-
- );
- }
- },
-
onCaptchaLoaded: function() {
if (this.refs.recaptchaContainer) {
var sitekey = this.authParams['m.login.recaptcha'].public_key;
@@ -308,7 +292,7 @@ module.exports = {
self.authParams = error.data.params;
self.authSessionId = error.data.session;
- self.completedStages = error.data.completed;
+ self.completedStages = error.data.completed || [];
var flow = self.chooseFlow(error.data.flows);