You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.4 KiB
39 lines
1.4 KiB
{% extends "base.html" %} |
|
{% block script %} |
|
<script> |
|
function run() { |
|
document.getElementById('login').addEventListener('click', function() { |
|
var username = document.getElementById('username').value; |
|
var password = document.getElementById('password').value; |
|
sha256(password).then(function(pwhash) { |
|
var credentials = {username: username, password_hash: pwhash} |
|
console.log(username, password, credentials); |
|
post_object('{{ url_for('journalmarks.login') }}', credentials) |
|
.then(journalmarks_initkey(username, password)).then(function() { |
|
window.location.href = '{{ next }}'; |
|
}).catch(function(error) { |
|
console.log('login error', error); |
|
}); |
|
}); |
|
}); |
|
|
|
document.getElementById('password').addEventListener('keyup', function(e) { |
|
if(e.keyCode == 13) |
|
document.getElementById('login').click(); |
|
}); |
|
} |
|
|
|
if (document.readyState!='loading') run(); |
|
else if (document.addEventListener) document.addEventListener('DOMContentLoaded', run); |
|
else document.attachEvent('onreadystatechange', function(){ |
|
if (document.readyState=='complete') run(); |
|
}); |
|
</script> |
|
{% endblock %} |
|
{% block body %} |
|
<h1>Login</h1> |
|
|
|
<input type="text" id="username"> |
|
<input type="password" id="password"> |
|
<button id="login">Login</button> |
|
{% endblock %}
|
|
|