66 lines
1.8 KiB
HTML
66 lines
1.8 KiB
HTML
<%inherit file="base.html" />
|
|
<%! from django.core.urlresolvers import reverse %>
|
|
<%block name="title">Log in</%block>
|
|
|
|
<%block name="content">
|
|
|
|
<article class="log-in-box">
|
|
<header>
|
|
<h1>Log in to edX</h1>
|
|
</header>
|
|
<form class="log-in-form" id="login_form" action="login_post" method="post">
|
|
<div class="row">
|
|
<label>Email:</label>
|
|
<input name="email" type="email" class="email-field">
|
|
</div>
|
|
<div class="row">
|
|
<label>Password:</label>
|
|
<input name="password" type="password" class="password-field">
|
|
</div>
|
|
<div class="row form-actions">
|
|
<input name="submit" type="submit" value="Log In" class="log-in-button">
|
|
<a href="#" class="forgot-button">Forgot password?</a>
|
|
</div>
|
|
</form>
|
|
<div class="log-in-extra">
|
|
<p>Not enrolled? <a href="${reverse('signup')}">Sign up.</a></p>
|
|
</div>
|
|
</article>
|
|
|
|
<script type="text/javascript">
|
|
(function() {
|
|
function getCookie(name) {
|
|
return $.cookie(name);
|
|
}
|
|
function postJSON(url, data, callback) {
|
|
$.ajax({type:'POST',
|
|
url: url,
|
|
dataType: 'json',
|
|
data: data,
|
|
success: callback,
|
|
headers : {'X-CSRFToken':getCookie('csrftoken')}
|
|
});
|
|
}
|
|
|
|
$('form#login_form').submit(function(e) {
|
|
e.preventDefault();
|
|
var submit_data = $('#login_form').serialize();
|
|
|
|
postJSON('/login_post',
|
|
submit_data,
|
|
function(json) {
|
|
if(json.success) {
|
|
location.href="${reverse('index')}";
|
|
} else if($('#login_error').length == 0) {
|
|
$('#login_form').prepend('<div id="login_error">Email or password is incorrect.</div>');
|
|
} else {
|
|
$('#login_error').stop().css("background-color", "#933").animate({ backgroundColor: "#333"}, 2000);
|
|
}
|
|
}
|
|
);
|
|
});
|
|
})(this)
|
|
</script>
|
|
|
|
</%block>
|