<div class="modal-header">
    <button type="button" class="close" ng-click="close()" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <h4 class="modal-title">
        <i class="fa fa-key"></i> Two-step Login <small>fido u2f</small>
    </h4>
</div>
<form name="authTwoStepForm" ng-submit="authTwoStepForm.$valid && auth(authModel)" api-form="authPromise"
      ng-if="!authed">
    <div class="modal-body">
        <p>Enter your master password to modify two-step login settings.</p>
        <div class="callout callout-danger validation-errors" ng-show="authTwoStepForm.$errors">
            <h4>Errors have occurred</h4>
            <ul>
                <li ng-repeat="e in authTwoStepForm.$errors">{{e}}</li>
            </ul>
        </div>
        <div class="form-group" show-errors>
            <label for="masterPassword">Master Password</label>
            <input type="password" id="masterPassword" name="MasterPasswordHash" ng-model="authModel.masterPassword"
                   class="form-control" required api-field />
        </div>
    </div>
    <div class="modal-footer">
        <button type="submit" class="btn btn-primary btn-flat" ng-disabled="authTwoStepForm.$loading">
            <i class="fa fa-refresh fa-spin loading-icon" ng-show="authTwoStepForm.$loading"></i>Continue
        </button>
        <button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
    </div>
</form>
<form name="submitTwoStepForm" ng-submit="submitTwoStepForm.$valid && submit()" api-form="submitPromise"
      ng-if="authed" autocomplete="off">
    <div class="modal-body">
        <div class="callout callout-warning">
            <h4><i class="fa fa-warning"></i> Warning <i class="fa fa-warning"></i></h4>
            <p>
                Due to platform limitations, FIDO U2F cannot be used on all Bitwarden applications. You should enable
                another two-step login provider so that you can access your account when FIDO U2F cannot be used.
            </p>
            <p>Supported platforms:</p>
            <ul>
                <li>
                    Web vault on a desktop/laptop with a U2F enabled browser (Chrome, Opera, Vivaldi, Brave, or Firefox with addon).
                </li>
                <li>Browser extensions on Chrome, Opera, Vivaldi, or Brave.</li>
            </ul>
        </div>
        <div ng-if="enabled">
            <div class="callout callout-success">
                <h4><i class="fa fa-check-circle"></i> Enabled</h4>
                <p>Two-step log via FIDO U2F is enabled on your account.</p>
            </div>
        </div>
        <div ng-if="!enabled">
            <div class="callout callout-danger validation-errors" ng-show="submitTwoStepForm.$errors">
                <h4>Errors have occurred</h4>
                <ul>
                    <li ng-repeat="e in submitTwoStepForm.$errors">{{e}}</li>
                </ul>
            </div>
            <p>To add a new FIDO U2F Security Key to your account:</p>
            <ol>
                <li>Plug the security key into your computer's USB port.</li>
                <li>If the security key has a button, touch it.</li>
            </ol>
            <hr />
            <div class="text-center">
                <div ng-show="deviceListening">
                    <p><i class="fa fa-spin fa-spinner fa-2x"></i></p>
                    <p>Waiting for you to touch the button on your security key...</p>
                </div>
                <div class="text-green" ng-show="deviceResponse">
                    <p><i class="fa fa-check-circle fa-2x"></i></p>
                    <p>Success!</p>
                    Click the "Enable" button below to enable this security key for two-step login.
                </div>
                <div class="text-red" ng-show="deviceError">
                    <p><i class="fa fa-warning fa-2x"></i></p>
                    <p>Error!</p>
                    <p>There was a problem reading the security key.</p>
                    <button type="button" class="btn btn-default btn-flat" ng-click="readDevice()">Try again</button>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button type="submit" class="btn btn-primary btn-flat"
                ng-disabled="(!enabled && !deviceResponse) || submitTwoStepForm.$loading">
            <i class="fa fa-refresh fa-spin loading-icon" ng-show="submitTwoStepForm.$loading"></i>
            {{enabled ? 'Disable' : 'Enable'}}
        </button>
        <button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
    </div>
</form>
