import { Card, Spinner } from '@automattic/components'; import { Button } from '@wordpress/components'; import clsx from 'clsx'; import { localize } from 'i18n-calypso'; import PropTypes from 'prop-types'; import { Component } from 'react'; import { connect } from 'react-redux'; import { recordTracksEventWithClientId as recordTracksEvent } from 'calypso/state/analytics/actions'; import { formUpdate, loginUserWithSecurityKey } from 'calypso/state/login/actions'; import TwoFactorActions from './two-factor-actions'; import './verification-code-form.scss'; import './security-key-form.scss'; class SecurityKeyForm extends Component { static propTypes = { formUpdate: PropTypes.func.isRequired, loginUserWithSecurityKey: PropTypes.func.isRequired, onSuccess: PropTypes.func.isRequired, recordTracksEvent: PropTypes.func.isRequired, switchTwoFactorAuthType: PropTypes.func.isRequired, translate: PropTypes.func.isRequired, showOrDivider: PropTypes.bool, isWoo: PropTypes.bool, }; static defaultProps = { isWoo: false, }; state = { isAuthenticating: false, }; componentDidMount() { this.initiateSecurityKeyAuthentication(); } initiateSecurityKeyAuthentication = () => { const { onSuccess } = this.props; this.setState( { isAuthenticating: true } ); this.props .loginUserWithSecurityKey() .then( () => onSuccess() ) .catch( () => this.setState( { isAuthenticating: false } ) ); }; render() { const { translate, isWoo, switchTwoFactorAuthType } = this.props; return (
); } } export default connect( null, { formUpdate, loginUserWithSecurityKey, recordTracksEvent, } )( localize( SecurityKeyForm ) );