diff --git a/static/app/components/superuserStaffAccessForm.tsx b/static/app/components/superuserStaffAccessForm.tsx index b2272041de2366..0e2d53d12598e6 100644 --- a/static/app/components/superuserStaffAccessForm.tsx +++ b/static/app/components/superuserStaffAccessForm.tsx @@ -59,9 +59,11 @@ class SuperuserStaffAccessForm extends Component { return; } - await this.getAuthenticators(); + const authenticators = await this.getAuthenticators(); + this.setState({authenticators: authenticators}); + // Set the error state if there are no authenticators and U2F is on - if (!this.state.authenticators.length && !disableU2FForSUForm) { + if (!authenticators.length && !disableU2FForSUForm) { this.handleError(ErrorCodes.NO_AUTHENTICATOR); } this.setState({isLoading: false}); @@ -183,10 +185,11 @@ class SuperuserStaffAccessForm extends Component { try { const authenticators = await api.requestPromise('/authenticators/'); - this.setState({authenticators: authenticators ?? []}); + return authenticators ?? []; } catch { // ignore errors } + return []; } render() {