<rd-header>
  <rd-header-title title-text="User settings"></rd-header-title>
  <rd-header-content>User settings</rd-header-content>
</rd-header>

<div class="row">
  <div class="col-lg-12 col-md-12 col-xs-12">
    <rd-widget>
      <rd-widget-header icon="fa-lock" title-text="Change user password"></rd-widget-header>
      <rd-widget-body>
        <form class="form-horizontal" style="margin-top: 15px;">
          <!-- current-password-input -->
          <div class="form-group">
            <label for="current_password" class="col-sm-2 control-label text-left">Current password</label>
            <div class="col-sm-8">
              <div class="input-group">
                <span class="input-group-addon"><i class="fa fa-lock" aria-hidden="true"></i></span>
                <input type="password" class="form-control" ng-model="formValues.currentPassword" id="current_password" />
              </div>
            </div>
          </div>
          <!-- !current-password-input -->
          <!-- new-password-input -->
          <div class="form-group">
            <label for="new_password" class="col-sm-2 control-label text-left">New password</label>
            <div class="col-sm-8">
              <div class="input-group">
                <span class="input-group-addon"><i class="fa fa-lock" aria-hidden="true"></i></span>
                <input type="password" class="form-control" ng-model="formValues.newPassword" id="new_password" />
              </div>
            </div>
          </div>
          <!-- !new-password-input -->
          <div class="form-group">
            <div class="col-sm-12">
              <i ng-class="{ true: 'fa fa-check green-icon', false: 'fa fa-times red-icon' }[formValues.newPassword.length >= 8]" aria-hidden="true"></i>
              <span class="small text-muted">Your new password must be at least 8 characters long</span>
            </div>
          </div>
          <!-- confirm-password-input -->
          <div class="form-group">
            <label for="confirm_password" class="col-sm-2 control-label text-left">Confirm password</label>
            <div class="col-sm-8">
              <div class="input-group">
                <span class="input-group-addon"><i class="fa fa-lock" aria-hidden="true"></i></span>
                <input type="password" class="form-control" ng-model="formValues.confirmPassword" id="confirm_password" />
                <span class="input-group-addon"
                  ><i
                    ng-class="
                      { true: 'fa fa-check green-icon', false: 'fa fa-times red-icon' }[formValues.newPassword !== '' && formValues.newPassword === formValues.confirmPassword]
                    "
                    aria-hidden="true"
                  ></i
                ></span>
              </div>
            </div>
          </div>
          <!-- !confirm-password-input -->
          <div class="form-group">
            <div class="col-sm-12">
              <button
                type="submit"
                class="btn btn-primary btn-sm"
                ng-disabled="(AuthenticationMethod !== 1 && userID !== 1) || !formValues.currentPassword || formValues.newPassword.length < 8 || formValues.newPassword !== formValues.confirmPassword"
                ng-click="updatePassword()"
                >Update password</button
              >
              <span class="text-muted small" style="margin-left: 5px;" ng-if="AuthenticationMethod === 2 && userID !== 1">
                <i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
                You cannot change your password when using LDAP authentication.
              </span>
              <span class="text-muted small" style="margin-left: 5px;" ng-if="AuthenticationMethod === 3 && userID !== 1">
                <i class="fa fa-exclamation-triangle" aria-hidden="true"></i>
                You cannot change your password when using OAuth authentication.
              </span>
            </div>
          </div>
        </form>
      </rd-widget-body>
    </rd-widget>
  </div>
</div>
