1
<!doctype html>
2
<head>
3
<script src="{{ url_for('static', filename='sjcl.js') }}" type="text/javascript"></script>
4
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
5
<link rel=stylesheet type=text/css href="{{ url_for('static', filename='bootstrap.min.css') }}">
6
<style type="text/css">
7
      body {
8
        padding-top: 40px;
9
        padding-bottom: 40px;
10
        background-color: #f5f5f5;
11
      }
12
13
      .form-signin {
14
        max-width: 300px;
15
        padding: 19px 29px 29px;
16
        margin: 0 auto 20px;
17
        background-color: #fff;
18
        border: 1px solid #e5e5e5;
19
        -webkit-border-radius: 5px;
20
           -moz-border-radius: 5px;
21
                border-radius: 5px;
22
        -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
23
           -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
24
                box-shadow: 0 1px 2px rgba(0,0,0,.05);
25
      }
26
      .form-signin .form-signin-heading,
27
      .form-signin .checkbox {
28
        margin-bottom: 10px;
29
      }
30
      .form-signin input[type="text"],
31
      .form-signin input[type="password"] {
32
        font-size: 16px;
33
        height: auto;
34
        margin-bottom: 15px;
35
        padding: 7px 9px;
36
      }
37
38
    </style>
39
</head>
40
{% block body %}
41
  {% if session.logged_in %}
42
<div class="container form-signin">
43
  <h2 class="form-signin-heading">Please create a user and assign a key</h2>
44
<input type=text id="user" name=user class="input-block-level" placeholder="Name">
45
<input id="password" class="input-block-level" type=password size=30 name=title placeholder="Password">
46
<button class="btn btn-large btn-primary" type=submit onclick="encryptAndSend();">Submit</button>
47
</div>
48
  {% endif %}
49
<script type="text/javascript">
50
function encryptAndSend()
51
{
52
key = {{ session.key| tojson| safe }}
53
data = $('#password').val();
54
var hash = sjcl.encrypt(key,data);
55
$.post({{ url_for('user')| tojson| safe }}, {'user':$("#user").val(), "key":hash}, function(data){
56
/*TODO: In the UI flash a "check mark", to indicate success.*/
57
console.log("Success");
58
});
59
60
}
61
</script>
62
{% endblock %}