@@ -26,6 +26,7 @@ type Props = {
26
26
} ;
27
27
28
28
type State = {
29
+ authenticators : Array < Authenticator > ;
29
30
error : boolean ;
30
31
errorType : string ;
31
32
isLoading : boolean ;
@@ -39,6 +40,7 @@ class SuperuserStaffAccessForm extends Component<Props, State> {
39
40
super ( props ) ;
40
41
this . authUrl = this . props . hasStaff ? '/staff-auth/' : '/auth/' ;
41
42
this . state = {
43
+ authenticators : [ ] ,
42
44
error : false ,
43
45
errorType : '' ,
44
46
showAccessForms : true ,
@@ -58,17 +60,16 @@ class SuperuserStaffAccessForm extends Component<Props, State> {
58
60
}
59
61
60
62
const authenticators = await this . getAuthenticators ( ) ;
61
- this . authenticators = authenticators ;
63
+ this . setState ( { authenticators : authenticators } ) ;
62
64
63
65
// Set the error state if there are no authenticators and U2F is on
64
- if ( ! this . authenticators . length && ! disableU2FForSUForm ) {
66
+ if ( ! authenticators . length && ! disableU2FForSUForm ) {
65
67
this . handleError ( ErrorCodes . NO_AUTHENTICATOR ) ;
66
68
}
67
69
this . setState ( { isLoading : false } ) ;
68
70
}
69
71
70
72
authUrl : string ;
71
- authenticators : Authenticator [ ] = [ ] ;
72
73
73
74
handleSubmitCOPS = ( ) => {
74
75
this . setState ( {
@@ -79,13 +80,13 @@ class SuperuserStaffAccessForm extends Component<Props, State> {
79
80
80
81
handleSubmit = async data => {
81
82
const { api} = this . props ;
82
- const { superuserAccessCategory, superuserReason} = this . state ;
83
+ const { superuserAccessCategory, superuserReason, authenticators } = this . state ;
83
84
const disableU2FForSUForm = ConfigStore . get ( 'disableU2FForSUForm' ) ;
84
85
85
86
const suAccessCategory = superuserAccessCategory || data . superuserAccessCategory ;
86
87
const suReason = superuserReason || data . superuserReason ;
87
88
88
- if ( ! this . authenticators . length && ! disableU2FForSUForm ) {
89
+ if ( ! authenticators . length && ! disableU2FForSUForm ) {
89
90
this . handleError ( ErrorCodes . NO_AUTHENTICATOR ) ;
90
91
return ;
91
92
}
@@ -192,7 +193,7 @@ class SuperuserStaffAccessForm extends Component<Props, State> {
192
193
}
193
194
194
195
render ( ) {
195
- const { error, errorType, showAccessForms, isLoading} = this . state ;
196
+ const { authenticators , error, errorType, showAccessForms, isLoading} = this . state ;
196
197
if ( errorType === ErrorCodes . INVALID_SSO_SESSION ) {
197
198
this . handleLogout ( ) ;
198
199
return null ;
@@ -211,7 +212,7 @@ class SuperuserStaffAccessForm extends Component<Props, State> {
211
212
</ StyledAlert >
212
213
) }
213
214
< U2fContainer
214
- authenticators = { this . authenticators }
215
+ authenticators = { authenticators }
215
216
displayMode = "sudo"
216
217
onTap = { this . handleU2fTap }
217
218
/>
@@ -239,7 +240,7 @@ class SuperuserStaffAccessForm extends Component<Props, State> {
239
240
{ showAccessForms && < Hook name = "component:superuser-access-category" /> }
240
241
{ ! showAccessForms && (
241
242
< U2fContainer
242
- authenticators = { this . authenticators }
243
+ authenticators = { authenticators }
243
244
displayMode = "sudo"
244
245
onTap = { this . handleU2fTap }
245
246
/>
0 commit comments