<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>duo</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(updateModel)" api-form="submitPromise"
      ng-if="authed" autocomplete="off">
    <div class="modal-body">
        <div ng-if="enabled">
            <div class="callout callout-success">
                <h4><i class="fa fa-check-circle"></i> Enabled</h4>
                <p>Two-step log via Duo is enabled on your account.</p>
            </div>
            <ul class="list-unstyled">
                <li><strong>Integration Key:</strong> {{updateModel.ikey}}</li>
                <li><strong>Secret Key:</strong> ************</li>
                <li><strong>API Hostname:</strong> {{updateModel.host}}</li>
            </ul>
        </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>Enter the bitwarden application information from your Duo Admin panel:</p>
            <div class="form-group" show-errors>
                <label for="ikey">Integration Key</label>
                <input type="text" id="ikey" name="IntegrationKey" ng-model="updateModel.ikey" class="form-control"
                       required api-field />
            </div>
            <div class="form-group" show-errors>
                <label for="skey">Secret Key</label>
                <input type="password" id="skey" name="SecretKey" ng-model="updateModel.skey" class="form-control"
                       required api-field autocomplete="new-password" />
            </div>
            <div class="form-group" show-errors>
                <label for="host">API Hostname</label>
                <input type="text" id="host" name="Host" placeholder="ex. api-xxxxxxxx.duosecurity.com"
                       ng-model="updateModel.host" class="form-control" required api-field />
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <button type="submit" class="btn btn-primary btn-flat" ng-disabled="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>
