{% extends "base.html" %}

{% block content %}

  <div class="row">
    <div class="form-group">
      <label for="token" class="col-sm-2 control-label">User Token</label>
      <div class="col-sm-4">
        <input name="token" type="text" class="form-control" id="token" placeholder="Token">
        <p class="help-block">Token received after login</p>
      </div>
    </div>
  </div>

  <div class="row">
    <h3>Update User Details</h3><hr/>
    {% include "fragments/password_change_form.html" %}
  </div>
{% endblock %}

{% block script %}
    <script type="text/javascript">
      $().ready(function(){
        $('form button[type=submit]').click(function(){
          var token = $('input[name=token]').val();
          var form = $('form');
          $.ajax({
            url: form.attr('action'),
            data: $('form').serialize(),
            type: "POST",
            beforeSend: function(xhr){xhr.setRequestHeader('Authorization', 'Token '+token);}
          }).fail(function(data){error_response(data);})
          .done(function(data){susccess_response(data);});
          return false;
        });

      });
    </script>
{% endblock %}
