Commit 9f093f98 by Ernie Park

update password reset form and change inputs to type submit and chmod executable html files

parent 92e5cff8
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div name="enroll_form" id="enroll_form"> <div name="enroll_form" id="enroll_form">
<h1>Enroll in 6.002 Circuits &amp; Electronics</h1> <h1>Enroll in 6.002 Circuits &amp; Electronics</h1>
<form name="login" method="get"> <form name="enroll" id="enroll_form" method="get">
<fieldset><% if 'error' in locals(): e = error %> <fieldset><% if 'error' in locals(): e = error %>
<div id="enroll_error" name="enroll_error"></div> <div id="enroll_error" name="enroll_error"></div>
...@@ -67,6 +67,6 @@ ...@@ -67,6 +67,6 @@
</li> </li>
</ol> </ol>
<input name="create_account_button" id="create_account_button" type="button" value="Create Account"> <input name="create_account_button" id="create_account_button" type="submit" value="Create Account">
</fieldset> </form> </fieldset> </form>
</div> </div>
...@@ -103,7 +103,8 @@ $(function() { ...@@ -103,7 +103,8 @@ $(function() {
/* Handles when the user hits 'enroll'. Grabs form data. Does AJAX. /* Handles when the user hits 'enroll'. Grabs form data. Does AJAX.
Either shows error, or shows success. */ Either shows error, or shows success. */
$('#create_account_button').click(function() { $('form#enroll_form').submit(function(e) {
e.preventDefault();
var submit_data={}; var submit_data={};
$.each($("[id^=ca_]"), function(index,value){ $.each($("[id^=ca_]"), function(index,value){
submit_data[value.name]=value.value; submit_data[value.name]=value.value;
......
...@@ -3,7 +3,7 @@ ${ error } ...@@ -3,7 +3,7 @@ ${ error }
<div id="login_div"> <div id="login_div">
<h1>Log in to MITx</h1> <h1>Log in to MITx</h1>
<form name="login" action="/login" method="get"> <form id="login_form" method="post">
<div id="login_error"></div> <div id="login_error"></div>
<ol> <ol>
<li> <li>
...@@ -21,7 +21,7 @@ ${ error } ...@@ -21,7 +21,7 @@ ${ error }
</li> </li>
</ol> </ol>
<input name="submit" id="login_button" type="button" value="Log in"> <input name="submit" id="login_button" type="submit" value="Log in">
</form> </form>
<div class="lost-password"> <div class="lost-password">
......
...@@ -66,14 +66,15 @@ ...@@ -66,14 +66,15 @@
</footer> </footer>
<div id="login" class="leanModal_box"><%include file="login.html" /></div> <div id="login" class="leanModal_box"><%include file="login.html" /></div>
<div id="pwd_reset" class="leanModal_box"><%include file="password_reset_form.html" /></div> <div id="pwd_reset" class="leanModal_box"><%include file="registration/password_reset_form.html" /></div>
<div id="reset_done" class="leanModal_box"></div> <div id="reset_done" class="leanModal_box"></div>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
/* Handles when the user tries to log in. Grabs form data. Does AJAX. /* Handles when the user tries to log in. Grabs form data. Does AJAX.
Either shows error, or redirects. */ Either shows error, or redirects. */
$('#login_button').click(function() { $('form#login_form').submit(function(e) {
e.preventDefault();
var submit_data={}; var submit_data={};
$.each($("[id^=li_]"), function(index,value){ $.each($("[id^=li_]"), function(index,value){
submit_data[value.name]=value.value; submit_data[value.name]=value.value;
...@@ -92,11 +93,21 @@ $(document).ready(function(){ ...@@ -92,11 +93,21 @@ $(document).ready(function(){
); );
}); });
$('#pwd_reset_button').click(function() {
$.post('/password_reset/',{ "csrfmiddlewaretoken" : "${ csrf }", $('form#pwd_reset_form').submit(function(e) {
"email" : $('#id_email').val()}, function(data){ e.preventDefault();
$('#pwd_reset').html(data); var submit_data = {};
}); submit_data['email'] = $('#id_email').val();
postJSON('/password_reset/',
submit_data,
function(json){
if (json.success) {
$('#pwd_reset').html(json.value);
} else {
$('#pwd_error').html(json.error);
}
}
);
}); });
}); });
......
<h1>Password reset</h1>
<p>Forgotten your password? Enter your e-mail address below, and we'll e-mail instructions for setting a new one.</p>
<form action="/password_reset/" method="post">
<input type='hidden' name='csrfmiddlewaretoken' value='${ csrf }' />
<label for="id_email">E-mail address:</label>
<input id="id_email" type="email" name="email" maxlength="75" /> <input type="button" id="pwd_reset_button" value="Reset my password" />
</form>
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
{% block content %}
<h1>Password reset successful</h1> <h1>Password reset successful</h1>
<p>We've e-mailed you instructions for setting your password to the e-mail address you submitted. You should be receiving it shortly.</p> <p>We've e-mailed you instructions for setting your password to the e-mail address you submitted. You should be receiving it shortly.</p>
{% endblock %}
File mode changed from 100755 to 100644
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
<p>Forgotten your password? Enter your e-mail address below, and we'll e-mail instructions for setting a new one.</p> <p>Forgotten your password? Enter your e-mail address below, and we'll e-mail instructions for setting a new one.</p>
<form action="" method="post">{% csrf_token %} <form id="pwd_reset_form">
{{ form.email.errors }} <div id="pwd_error"></div>
<p><label for="id_email">E-mail address:</label> {{ form.email }} <input type="submit" value="Reset my password" /></p> <label for="id_email">E-mail address:</label>
<input id="id_email" type="email" name="email" maxlength="75" />
<input type="submit" id="pwd_reset_button" value="Reset my password" />
</form> </form>
...@@ -93,7 +93,7 @@ div.leanModal_box { ...@@ -93,7 +93,7 @@ div.leanModal_box {
} }
} }
input[type="button"] { input[type="button"], input[type="submit"] {
@include button($mit-red); @include button($mit-red);
font-size: 18px; font-size: 18px;
padding: lh(.5); padding: lh(.5);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment