{% extends 'TopxiaWebBundle:Settings:layout.html.twig' %}

{% block title %}密码修改 - {{ parent() }}{% endblock %}

{% set script_controller = 'settings/password' %}
{% set side_nav = 'password' %}

{% block main %}
  {% embed "TopxiaWebBundle:Bootstrap:panel.html.twig" with {class:'panel-col'} %}
    {% block heading %}密码修改{% endblock %}
    {% block body %}
      {% if not app.user.password %}
        <div class="alert alert-warning">
          <p>当前帐号从第三方帐号直接登录时创建，尚未设置密码。</p>
          <p>为了帐号的安全，请通过邮箱找回密码的方式，重设密码！</p>
          <p><a href="{{ path('password_reset') }}" class="btn btn-primary">现在就去重设密码！</a></p>
        </div>
      {% endif %}

      <form id="settings-password-form" class="form-horizontal" method="post" {% if not app.user.password %} style="display:none;"{% endif %}>

        {{ web_macro.flash_messages() }}
        
        <div class="form-group">
          <div class="col-md-2 control-label">{{ form_label(form.currentPassword, '当前密码') }}</div>
          <div class="controls col-md-8 controls">
            {{ form_widget(form.currentPassword, {attr:{class:'form-control'}}) }}
          </div>
        </div>

        <div class="form-group">
          <div class="col-md-2 control-label">{{ form_label(form.newPassword, '新密码') }}</div>
          <div class="controls col-md-8 controls">
            {{ form_widget(form.newPassword, {attr:{class:'form-control'}}) }}
          </div>
        </div>

        <div class="form-group">
          <div class="col-md-2 control-label">{{ form_label(form.confirmPassword, '确认密码') }}</div>
          <div class="controls col-md-8 controls">
            {{ form_widget(form.confirmPassword, {attr:{class:'form-control'}}) }}
          </div>
        </div>

        <div class="form-group">
          <div class="col-md-2 control-label"></div>
          <div class="controls col-md-8 controls">
            {{ form_rest(form) }}
            <button id="password-save-btn" data-submiting-text="正在保存" type="submit" class="btn btn-primary">提交</button>
          </div>
        </div>

        <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">

      </form>
    {% endblock %}
  {% endembed %}
{% endblock %}