@@ -27,7 +27,7 @@ import StyleProps from '../../styleUtils/StyleProps'
2727
2828import errorIcon from './images/error.svg'
2929
30- import { loginButtons } from '../../../config'
30+ import { loginButtons , showUserDomainInput } from '../../../config'
3131import notificationStore from '../../../stores/NotificationStore'
3232
3333const Form = styled . form `
@@ -87,7 +87,12 @@ type Props = {
8787 className : string ,
8888 loading : boolean ,
8989 loginFailedResponse : { status : string , message ?: string } ,
90- onFormSubmit : ( credentials : { username : string , password : string } ) => void ,
90+ domain : string ,
91+ onDomainChange : ( domain : string ) => void ,
92+ onFormSubmit : ( credentials : {
93+ username : string ,
94+ password : string ,
95+ } ) => void ,
9196}
9297type State = {
9398 username : string ,
@@ -112,13 +117,20 @@ class LoginForm extends React.Component<Props, State> {
112117 this . setState ( { password } )
113118 }
114119
120+ handleDomainChange ( domain : string ) {
121+ this . props . onDomainChange ( domain )
122+ }
123+
115124 handleFormSubmit ( e : Event ) {
116125 e . preventDefault ( )
117126
118- if ( this . state . username . length === 0 || this . state . password . length === 0 ) {
127+ if ( ! this . state . username . length || ! this . state . password . length || ! this . props . domain . length ) {
119128 notificationStore . alert ( 'Please fill in all fields' )
120129 } else {
121- this. props . onFormSubmit ( { username : this . state . username , password : this . state . password } )
130+ this . props . onFormSubmit ( {
131+ username : this . state . username ,
132+ password : this . state . password ,
133+ } )
122134 }
123135 }
124136
@@ -132,7 +144,7 @@ class LoginForm extends React.Component<Props, State> {
132144 if ( this . props . loginFailedResponse . status ) {
133145 switch ( this . props . loginFailedResponse . status ) {
134146 case 401 :
135- errorMessage = 'The username or password did not match. Please try again.'
147+ errorMessage = 'Incorrect credentials.<br /> Please try again.'
136148 break
137149 default :
138150 errorMessage = this . props . loginFailedResponse . message || errorMessage
@@ -142,9 +154,10 @@ class LoginForm extends React.Component<Props, State> {
142154 return (
143155 < LoginError >
144156 < LoginErrorIcon />
145- < LoginErrorText data-test-id = "loginForm-errorText" >
146- { errorMessage }
147- </ LoginErrorText >
157+ < LoginErrorText
158+ data-test-id = "loginForm-errorText"
159+ dangerouslySetInnerHTML = { { __html : errorMessage } }
160+ />
148161 </ LoginError >
149162 )
150163 }
@@ -169,6 +182,13 @@ class LoginForm extends React.Component<Props, State> {
169182 < LoginOptions />
170183 { loginSeparator }
171184 < FormFields >
185+ { showUserDomainInput ? (
186+ < LoginFormField
187+ label = "Domain Name"
188+ value = { this . props . domain }
189+ onChange = { e => { this . handleDomainChange ( e . target . value ) } }
190+ />
191+ ) : null }
172192 < LoginFormField
173193 label = "Username"
174194 value = { this . state . username }
0 commit comments