@@ -27,7 +27,9 @@ var ComponentBroker = require("../../ComponentBroker");
2727module . exports = {
2828 FieldErrors : {
2929 PasswordMismatch : 'PasswordMismatch' ,
30- PasswordLength : 'PasswordLength'
30+ TooShort : 'TooShort' ,
31+ Missing : 'Missing' ,
32+ InUse : 'InUse'
3133 } ,
3234
3335 getInitialState : function ( ) {
@@ -166,10 +168,18 @@ module.exports = {
166168 if ( formVals . password != formVals . confirmPassword ) {
167169 badFields . confirmPassword = this . FieldErrors . PasswordMismatch ;
168170 }
169- if ( formVals . password . length < 6 ) {
170- badFields . password = this . FieldErrors . PasswordLength ;
171+ if ( formVals . password == '' ) {
172+ badFields . password = this . FieldErrors . Missing ;
173+ } else if ( formVals . password . length < 6 ) {
174+ badFields . password = this . FieldErrors . Length ;
175+ }
176+ if ( formVals . username == '' ) {
177+ badFields . username = this . FieldErrors . Missing ;
178+ }
179+ if ( Object . keys ( badFields ) . length > 0 ) {
180+ this . onBadFields ( badFields ) ;
181+ return ;
171182 }
172- this . onBadFields ( badFields ) ;
173183
174184 MatrixClientPeg . replaceUsingUrls (
175185 this . getHsUrl ( ) ,
@@ -308,15 +318,20 @@ module.exports = {
308318 } ) ;
309319 self . startStage ( flow . stages [ flowStage ] ) ;
310320 } else {
311- var errorText = "Unable to contact the given Home Server" ;
312- if ( error . httpStatus == 401 ) {
313- errorText = "Authorisation failed!" ;
314- }
315321 self . setStep ( "initial" ) ;
316- self . setState ( {
322+ var newState = {
317323 busy : false ,
318- errorText : errorText
319- } ) ;
324+ errorText : "Unable to contact the given Home Server"
325+ } ;
326+ if ( error . name == 'M_USER_IN_USE' ) {
327+ delete newState . errorText ;
328+ self . onBadFields ( {
329+ username : self . FieldErrors . InUse
330+ } ) ;
331+ } else if ( error . httpStatus == 401 ) {
332+ newState . errorText = "Authorisation failed!" ;
333+ }
334+ self . setState ( newState ) ;
320335 }
321336 } ) ;
322337 } ,
0 commit comments