@@ -9,6 +9,7 @@ import {basename} from '../../store';
99import { authenticationApi } from '../../store/reducers/authentication/authentication' ;
1010import { useLoginWithDatabase } from '../../store/reducers/capabilities/hooks' ;
1111import { cn } from '../../utils/cn' ;
12+ import { prepareCommonErrorMessage } from '../../utils/errors' ;
1213import { useMetaAuth } from '../../utils/hooks/useMetaAuth' ;
1314
1415import { isDatabaseError , isPasswordError , isUserError } from './utils' ;
@@ -68,23 +69,28 @@ function Authentication({closable = false}: AuthenticationProps) {
6869 const [ loginError , setLoginError ] = React . useState ( '' ) ;
6970 const [ passwordError , setPasswordError ] = React . useState ( '' ) ;
7071 const [ databaseError , setDatabaseError ] = React . useState ( '' ) ;
72+ const [ generalError , setGeneralError ] = React . useState ( '' ) ;
7173 const [ showPassword , setShowPassword ] = React . useState ( false ) ;
7274
7375 const onLoginUpdate = ( value : string ) => {
7476 setLogin ( value ) ;
7577 setLoginError ( '' ) ;
78+ setGeneralError ( '' ) ;
7679 } ;
7780 const onDatabaseUpdate = ( value : string ) => {
7881 setDatabase ( value ) ;
7982 setDatabaseError ( '' ) ;
83+ setGeneralError ( '' ) ;
8084 } ;
8185
8286 const onPassUpdate = ( value : string ) => {
8387 setPass ( value ) ;
8488 setPasswordError ( '' ) ;
89+ setGeneralError ( '' ) ;
8590 } ;
8691
8792 const onLoginClick = ( ) => {
93+ setGeneralError ( '' ) ;
8894 authenticate ( { user : login , password, database, useMeta} )
8995 . unwrap ( )
9096 . then ( ( ) => {
@@ -93,6 +99,8 @@ function Authentication({closable = false}: AuthenticationProps) {
9399 }
94100 } )
95101 . catch ( ( error ) => {
102+ const isInputError =
103+ isUserError ( error ) || isPasswordError ( error ) || isDatabaseError ( error ) ;
96104 if ( isUserError ( error ) ) {
97105 setLoginError ( error . data . error ) ;
98106 }
@@ -102,6 +110,11 @@ function Authentication({closable = false}: AuthenticationProps) {
102110 if ( isDatabaseError ( error ) ) {
103111 setDatabaseError ( error . data . error ) ;
104112 }
113+
114+ if ( ! isInputError ) {
115+ const message = prepareCommonErrorMessage ( error ) ;
116+ setGeneralError ( message ) ;
117+ }
105118 } ) ;
106119 } ;
107120
@@ -184,6 +197,8 @@ function Authentication({closable = false}: AuthenticationProps) {
184197 >
185198 Sign in
186199 </ Button >
200+ { /* always preserve place for general error to prevent container height jumping */ }
201+ < div className = { b ( 'general-error' ) } > { generalError } </ div >
187202 </ form >
188203 { closable && history . length > 1 && (
189204 < Button onClick = { onClose } className = { b ( 'close' ) } >
0 commit comments