{% extends "pylucid_admin/base_site.html" %}
{% load i18n %}


{% block extrahead %}{{ block.super }}
<style type="text/css">
#login_form, #sha_values_block, #js_page_msg {
    display: none; 
}
#js_page_msg { padding: 0.5em; }
.page_msg_success { color: #000000; border: 1px solid #00ff00; }
.page_msg_error { color: #ff0000; border: 1px solid #ff0000; }
.page_msg_info { color: #0000ff; border: 1px solid #000000; }
</style>

<script type="text/javascript">
var challenge="{{ challenge }}"; {# changed via ajax, after wrong login #}
var next_url="{{ next_url }}";
</script>
<script type="text/javascript" src="{% url django.views.i18n.javascript_catalog packages="auth" %}"></script>

<script type="text/javascript" src="{{ STATIC_URL }}PyLucid/auth/sha.js" onerror="JavaScript:alert('Error loading file ['+this.src+'] !');"></script>
<script type="text/javascript" src="{{ STATIC_URL }}PyLucid/auth/shared_sha_tools.js" onerror="JavaScript:alert('Error loading file ['+this.src+'] !');"></script>
<script type="text/javascript">
var OLD_SALT_LEN=parseInt("{{ old_salt_len }}");
var SALT_LEN=parseInt("{{ salt_len }}");
var HASH_LEN=parseInt("{{ hash_len }}");
var LOOP_COUNT=parseInt("{{ loop_count }}");
var sha_login_salt="{{ sha_login_salt }}";
var sha_auth_url="{{ sha_auth_url }}";
var get_salt_url="{{ get_salt_url }}";
jQuery(document).ready(function($) {
    init_JS_password_change();
});
</script>
{% endblock %}

{% block content %}

<fieldset>
<noscript>
    <h1>{% trans 'Error' %}</h1>
    <h3>Error: Javascript needed!</h3>
    <p>Without JavaScript, you can only use the unsecure plaintext password change!</p>
    </fieldset>
</noscript>

<p id="load_info">{% trans "loading..." %}</p>

<form method="post" action="" name="login" id="change_password_form" autocomplete="off">
  {% csrf_token %}
  <p id="js_page_msg"></p>
  <p id="password_block">
  	<label for="id_old_password">{% trans "Old Password" %}:</label>
	<input id="id_old_password" type="password" name="old_password" maxlength="128" required="required" autocomplete="off" />
  </p>
  
    <dl id="sha_values_block">
        <dt>old password "JS-SHA1" values for pre-verification:</dt>
        <dd>
            <dl>
                <dt>SHA A:</dt>
                <dd><input readonly="readonly" name="sha_a" maxlength="{{ hash_len }}" type="text" id="id_sha_a" size="{{ hash_len }}" autocomplete="off" /></dd>
                <dt>SHA B:</dt>
                <dd><input readonly="readonly" name="sha_b" maxlength="20" type="text" id="id_sha_b" size="20" autocomplete="off" /></dd>
                <dt>client nonce:</dt>
                <dd><input readonly="readonly" name="cnonce" maxlength="{{ hash_len }}" type="text" id="id_cnonce" size="{{ hash_len }}" autocomplete="off" /></dd>
            </dl>
        </dd> 
        <dt>new password as salted SHA1 hash:</dt>
        <dd>
            <dl>
                <dt>salt</dt>
                <dd><input readonly="readonly" name="salt" maxlength="40" type="text" id="id_salt" size="40" autocomplete="off" /></dd>
                <dt>SHA1 hash</dt>
                <dd><input readonly="readonly" name="sha1hash" maxlength="{{ hash_len }}" type="text" id="id_sha1hash" size="{{ hash_len }}" autocomplete="off" /></dd>
            </dl>
        </dd>  
    </dl>
  <p id="new_password_block">
    <label for="id_new_password1">{% trans "New Password" %}:</label>
    <input id="id_new_password1" type="password" name="new_password1" maxlength="128" required="required" autocomplete="off" />
    <label for="id_new_password2">{% trans "Confirm new Password" %}:</label>
    <input id="id_new_password2" type="password" name="new_password1" maxlength="128" required="required" autocomplete="off" />
  </p>
  <input id="submit_button" type="submit" value="{% trans 'Save' %}" />
</form>
{% if pass_reset_link %}{# only available if django-authopenid is installed #}
  <a href="{{ pass_reset_link }}">{% trans 'Request a password reset.' %}</a>
{% endif %}
</fieldset>
{% endblock %}