File tree Expand file tree Collapse file tree 1 file changed +30
-3
lines changed
Expand file tree Collapse file tree 1 file changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,26 @@ export default class Login extends React.Component {
2727 } ;
2828 sessionStorage . clear ( ) ;
2929 setBasePath ( props . path ) ;
30+ this . inputRefUser = React . createRef ( ) ;
31+ this . inputRefPass = React . createRef ( ) ;
32+ this . inputRefMfa = React . createRef ( ) ;
33+ }
34+
35+ componentDidMount ( ) {
36+ if ( this . errors ) {
37+ const e = this . errors . toLowerCase ( ) ;
38+ if ( e . includes ( 'missing credentials' ) || e . includes ( 'invalid username or password' ) ) {
39+ if ( this . inputRefUser . current . value . length < 1 ) {
40+ this . inputRefUser . current . focus ( ) ;
41+ } else {
42+ this . inputRefPass . current . focus ( ) ;
43+ }
44+ } else if ( e . includes ( 'one-time' ) ) {
45+ this . inputRefMfa . current . focus ( ) ;
46+ }
47+ } else {
48+ this . inputRefUser . current . focus ( ) ;
49+ }
3050 }
3151
3252 render ( ) {
@@ -54,7 +74,7 @@ export default class Login extends React.Component {
5474 type = 'username'
5575 value = { this . state . username }
5676 onChange = { e => updateField ( 'username' , e ) }
57- autoFocus
77+ ref = { this . inputRefUser }
5878 />
5979 } />
6080 < LoginRow
@@ -65,13 +85,20 @@ export default class Login extends React.Component {
6585 type = 'password'
6686 value = { this . state . password }
6787 onChange = { e => updateField ( 'password' , e ) }
88+ ref = { this . inputRefPass }
6889 />
6990 } />
7091 {
7192 this . errors && this . errors . includes ( 'one-time' ) ?
7293 < LoginRow
73- label = 'OTP'
74- input = { < input name = 'otpCode' type = 'number' /> } />
94+ label = 'OTP'
95+ input = {
96+ < input
97+ name = 'otpCode'
98+ type = 'number'
99+ ref = { this . inputRefMfa }
100+ />
101+ } />
75102 : null
76103 }
77104 { this . errors ?
You can’t perform that action at this time.
0 commit comments