Skip to content

Commit c946f52

Browse files
Revert "nit: Remove authenticators from state (#70365)"
This reverts commit 81d3fef. Co-authored-by: cathteng <[email protected]>
1 parent ad22def commit c946f52

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Diff for: static/app/components/superuserStaffAccessForm.tsx

+9-8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type Props = {
2626
};
2727

2828
type State = {
29+
authenticators: Array<Authenticator>;
2930
error: boolean;
3031
errorType: string;
3132
isLoading: boolean;
@@ -39,6 +40,7 @@ class SuperuserStaffAccessForm extends Component<Props, State> {
3940
super(props);
4041
this.authUrl = this.props.hasStaff ? '/staff-auth/' : '/auth/';
4142
this.state = {
43+
authenticators: [],
4244
error: false,
4345
errorType: '',
4446
showAccessForms: true,
@@ -58,17 +60,16 @@ class SuperuserStaffAccessForm extends Component<Props, State> {
5860
}
5961

6062
const authenticators = await this.getAuthenticators();
61-
this.authenticators = authenticators;
63+
this.setState({authenticators: authenticators});
6264

6365
// Set the error state if there are no authenticators and U2F is on
64-
if (!this.authenticators.length && !disableU2FForSUForm) {
66+
if (!authenticators.length && !disableU2FForSUForm) {
6567
this.handleError(ErrorCodes.NO_AUTHENTICATOR);
6668
}
6769
this.setState({isLoading: false});
6870
}
6971

7072
authUrl: string;
71-
authenticators: Authenticator[] = [];
7273

7374
handleSubmitCOPS = () => {
7475
this.setState({
@@ -79,13 +80,13 @@ class SuperuserStaffAccessForm extends Component<Props, State> {
7980

8081
handleSubmit = async data => {
8182
const {api} = this.props;
82-
const {superuserAccessCategory, superuserReason} = this.state;
83+
const {superuserAccessCategory, superuserReason, authenticators} = this.state;
8384
const disableU2FForSUForm = ConfigStore.get('disableU2FForSUForm');
8485

8586
const suAccessCategory = superuserAccessCategory || data.superuserAccessCategory;
8687
const suReason = superuserReason || data.superuserReason;
8788

88-
if (!this.authenticators.length && !disableU2FForSUForm) {
89+
if (!authenticators.length && !disableU2FForSUForm) {
8990
this.handleError(ErrorCodes.NO_AUTHENTICATOR);
9091
return;
9192
}
@@ -192,7 +193,7 @@ class SuperuserStaffAccessForm extends Component<Props, State> {
192193
}
193194

194195
render() {
195-
const {error, errorType, showAccessForms, isLoading} = this.state;
196+
const {authenticators, error, errorType, showAccessForms, isLoading} = this.state;
196197
if (errorType === ErrorCodes.INVALID_SSO_SESSION) {
197198
this.handleLogout();
198199
return null;
@@ -211,7 +212,7 @@ class SuperuserStaffAccessForm extends Component<Props, State> {
211212
</StyledAlert>
212213
)}
213214
<U2fContainer
214-
authenticators={this.authenticators}
215+
authenticators={authenticators}
215216
displayMode="sudo"
216217
onTap={this.handleU2fTap}
217218
/>
@@ -239,7 +240,7 @@ class SuperuserStaffAccessForm extends Component<Props, State> {
239240
{showAccessForms && <Hook name="component:superuser-access-category" />}
240241
{!showAccessForms && (
241242
<U2fContainer
242-
authenticators={this.authenticators}
243+
authenticators={authenticators}
243244
displayMode="sudo"
244245
onTap={this.handleU2fTap}
245246
/>

0 commit comments

Comments
 (0)