Show validation errors
This commit is contained in:
parent
ed3527e243
commit
b4c0625961
|
@ -22,6 +22,7 @@ var sdk = require('matrix-react-sdk');
|
||||||
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
||||||
var ServerConfig = require("./ServerConfig");
|
var ServerConfig = require("./ServerConfig");
|
||||||
var RegistrationForm = require("./RegistrationForm");
|
var RegistrationForm = require("./RegistrationForm");
|
||||||
|
var MIN_PASSWORD_LENGTH = 6;
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'Registration',
|
displayName: 'Registration',
|
||||||
|
@ -61,7 +62,40 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onFormValidationFailed: function(errCode) {
|
onFormValidationFailed: function(errCode) {
|
||||||
console.error("Ruh roh: %s", errCode);
|
var errMsg;
|
||||||
|
switch (errCode) {
|
||||||
|
case "RegistrationForm.ERR_PASSWORD_MISSING":
|
||||||
|
errMsg = "Missing password.";
|
||||||
|
break;
|
||||||
|
case "RegistrationForm.ERR_PASSWORD_MISMATCH":
|
||||||
|
errMsg = "Passwords don't match.";
|
||||||
|
break;
|
||||||
|
case "RegistrationForm.ERR_PASSWORD_LENGTH":
|
||||||
|
errMsg = `Password too short (min ${MIN_PASSWORD_LENGTH}).`;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.error("Unknown error code: %s", errCode);
|
||||||
|
errMsg = "An unknown error occurred.";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.setState({
|
||||||
|
errorText: errMsg
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
_getPostRegisterJsx: function() {
|
||||||
|
var ChangeDisplayName = sdk.getComponent('molecules.ChangeDisplayName');
|
||||||
|
var ChangeAvatar = sdk.getComponent('molecules.ChangeAvatar');
|
||||||
|
return (
|
||||||
|
<div className="mx_Login_profile">
|
||||||
|
Set a display name:
|
||||||
|
<ChangeDisplayName />
|
||||||
|
Upload an avatar:
|
||||||
|
<ChangeAvatar
|
||||||
|
initialAvatarUrl={MatrixClientPeg.get().mxcUrlToHttp(this.state.avatarUrl)} />
|
||||||
|
<button onClick={this.onProfileContinueClicked}>Continue</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
_getRegisterContentJsx: function() {
|
_getRegisterContentJsx: function() {
|
||||||
|
@ -74,7 +108,7 @@ module.exports = React.createClass({
|
||||||
registerStep = (
|
registerStep = (
|
||||||
<RegistrationForm
|
<RegistrationForm
|
||||||
showEmail={true}
|
showEmail={true}
|
||||||
minPasswordLength={8}
|
minPasswordLength={MIN_PASSWORD_LENGTH}
|
||||||
onError={this.onFormValidationFailed}
|
onError={this.onFormValidationFailed}
|
||||||
onRegisterClick={this.onFormSubmit} />
|
onRegisterClick={this.onFormSubmit} />
|
||||||
);
|
);
|
||||||
|
@ -117,21 +151,6 @@ module.exports = React.createClass({
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
_getPostRegisterJsx: function() {
|
|
||||||
var ChangeDisplayName = sdk.getComponent('molecules.ChangeDisplayName');
|
|
||||||
var ChangeAvatar = sdk.getComponent('molecules.ChangeAvatar');
|
|
||||||
return (
|
|
||||||
<div className="mx_Login_profile">
|
|
||||||
Set a display name:
|
|
||||||
<ChangeDisplayName />
|
|
||||||
Upload an avatar:
|
|
||||||
<ChangeAvatar
|
|
||||||
initialAvatarUrl={MatrixClientPeg.get().mxcUrlToHttp(this.state.avatarUrl)} />
|
|
||||||
<button onClick={this.onProfileContinueClicked}>Continue</button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
return (
|
return (
|
||||||
<div className="mx_Login">
|
<div className="mx_Login">
|
||||||
|
|
|
@ -176,12 +176,17 @@ module.exports = React.createClass({
|
||||||
/>
|
/>
|
||||||
); */
|
); */
|
||||||
return (
|
return (
|
||||||
|
var registerLogic = new Signup.Register(
|
||||||
|
config.default_hs_url, config.default_is_url
|
||||||
|
);
|
||||||
|
registerLogic.setClientSecret(this.state.register_client_secret);
|
||||||
|
registerLogic.setSessionId(this.state.register_session_id);
|
||||||
|
registerLogic.setRegistrationUrl(this.props.registrationUrl);
|
||||||
|
registerLogic.setIdSid(this.state.register_id_sid);
|
||||||
<Registration
|
<Registration
|
||||||
onLoggedIn={this.onLoggedIn}
|
onLoggedIn={this.onLoggedIn}
|
||||||
onLoginClick={this.onLoginClick}
|
onLoginClick={this.onLoginClick}
|
||||||
registerLogic={new Signup.Register(
|
registerLogic={registerLogic} />
|
||||||
config.default_hs_url, config.default_is_url
|
|
||||||
)} />
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue