{{template "base/base.html" .}}

{{define "meta"}}
<link href="/static/css/user.css" rel="stylesheet">
{{end}}

{{define "body"}}
<center><h2 class="form-signin-heading">Chagement de mot de passe</h2></center>
<form id="chPwdForm" class="form-signin" action="/user" method="POST">
  <label for="inputJID" class="sr-only">Jabber ID</label>
  <input type="text" id="jid" name="jid" class="form-control" placeholder="Jabber ID"
  {{if .user}}
    value="{{.user.JID}}"
  {{end}}
  >

  <label for="password1" class="sr-only">Mot de passe</label>
  <input type="password" id="password1" name="password1" class="form-control" placeholder="Password" >

  <label for="password2" class="sr-only">Mot de passe</label>
  <input type="password" id="password2" name="password2" class="form-control" placeholder="Password" >

  <button class="btn btn-lg btn-primary btn-block" type="submit">Enregistrer</button>
</form>
{{end}}

{{define "extrajs"}}
<script src="/static/js/jquery.sha256.min.js"></script>
<script type="application/javascript">
$("#chPwdForm").submit(function() {
    var pwd1old = $('#password1').val();
    var pwd2old = $('#password2').val();
    if (pwd1old != pwd2old) {
        return false;
    }

    if (pwd1old != "") {
        $('#password1').val($.sha256(pwd1old));
        $('#password2').val($.sha256(pwd2old));
    }
    console.log("Password1: "+$('#password1').val());
    console.log("Password2: "+$('#password2').val());
    
    return $('#password1').val() == $('#password2').val();
});
</script>
{{end}}
