{% extends 'layout.html.twig' %}
{% block title %}{{'设置登录密码'|trans}} - {{ parent() }}{% endblock %}
{% set hideSetupHint = true %}
{% do script(['libs/jquery-validation.js','app/js/settings/setup-password/index.js'])%}

{% block content %}
<div class="row row-6">
  <div class="col-md-6 col-md-offset-3">

    <div class="panel panel-default panel-page">
      <div class="panel-heading"><h2>{{'设置登录密码'|trans}}</h2></div>

      {% if not app.user.password %}
        <form id="setup-password-form" class="form-vertical" method="post" action="{{ path('settings_setup_password') }}">

          {{ web_macro.flash_messages() }}
          <div class="alert alert-warning"> {{'为了帐号的安全以及更好的使用体验，请设置以下信息。'|trans}} </div>

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

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

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

          <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
        </form>
      {% else %}
        <div class="alert alert-danger">
          <p>{{'该帐号已经设置过密码，不能再次设置！'|trans}}</p>
          <p><a href="{{ path('homepage') }}" class="btn btn-primary">{{'返回首页'|trans}}</a></p>
        </div>
      {% endif %}

    </div>

  </div>
</div>
{% endblock %}