<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>authenticator app</small>
    </h4>
</div>
<form name="authTwoStepForm" ng-submit="authTwoStepForm.$valid && auth(authModel)" api-form="authPromise"
      ng-if="!model">
    <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="model" 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 login via authenticator app is enabled on your account.
                </p>
                <p>
                    In case you need to add it to another device, below is the QR code (or key) required by your
                    authenticator app.
                </p>
            </div>
            <p>Need a two-step authenticator app? Download one of the following:</p>
        </div>
        <div ng-if="!enabled">
            <p>Setting up two-step login with an authenticator app is easy, just follow these steps:</p>
            <h4>1. Download a two-step authenticator app</h4>
        </div>
        <ul class="fa-ul">
            <li>
                <i class="fa-li fa fa-apple fa-lg"></i>
                iOS devices:
                <a href="https://itunes.apple.com/us/app/authy/id494168017?mt=8" target="_blank">
                    Authy for iOS
                </a>
            </li>
            <li>
                <i class="fa-li fa fa-android fa-lg"></i>
                Android devices:
                <a href="https://play.google.com/store/apps/details?id=com.authy.authy" target="_blank">
                    Authy for Android
                </a>
            </li>
            <li>
                <i class="fa-li fa fa-windows fa-lg"></i>
                Windows devices:
                <a href="https://www.microsoft.com/en-us/store/apps/authenticator/9wzdncrfj3rj" target="_blank">
                    Microsoft Authenticator
                </a>
            </li>
        </ul>
        <p>These apps are recommended, however, other authenticator apps will also work.</p>
        <hr ng-if="enabled" />
        <h4 ng-if="!enabled" style="margin-top: 30px;">2. Scan this QR code with your authenticator app</h4>
        <div class="row">
            <div class="col-sm-4 text-center">
                <p><img ng-src="{{model.qr}}" alt="QR" /></p>
            </div>
            <div class="col-sm-8">
                <p>
                    <strong>Can't scan the code?</strong> You can add the code to your application manually using the
                    following details:
                </p>
                <ul class="list-unstyled">
                    <li><strong>Key:</strong> <code>{{model.key}}</code></li>
                    <li><strong>Account:</strong> {{account}}</li>
                    <li><strong>Time based:</strong> Yes</li>
                </ul>
            </div>
        </div>
        <div ng-if="!enabled">
            <h4 style="margin-top: 30px;">
                3. Enter the resulting 6 digit verification code from the app
            </h4>
            <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>
            <div class="form-group" show-errors>
                <label for="token" class="sr-only">Verification Code</label>
                <input type="text" id="token" name="Token" placeholder="Verification Code" ng-model="updateModel.token"
                       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>