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 {
27
27
} ;
28
28
sessionStorage . clear ( ) ;
29
29
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
+ }
30
50
}
31
51
32
52
render ( ) {
@@ -54,7 +74,7 @@ export default class Login extends React.Component {
54
74
type = 'username'
55
75
value = { this . state . username }
56
76
onChange = { e => updateField ( 'username' , e ) }
57
- autoFocus
77
+ ref = { this . inputRefUser }
58
78
/>
59
79
} />
60
80
< LoginRow
@@ -65,13 +85,20 @@ export default class Login extends React.Component {
65
85
type = 'password'
66
86
value = { this . state . password }
67
87
onChange = { e => updateField ( 'password' , e ) }
88
+ ref = { this . inputRefPass }
68
89
/>
69
90
} />
70
91
{
71
92
this . errors && this . errors . includes ( 'one-time' ) ?
72
93
< 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
+ } />
75
102
: null
76
103
}
77
104
{ this . errors ?
You can’t perform that action at this time.
0 commit comments