app/views/caboose/users/edit_password.html.erb in caboose-cms-0.3.26 vs app/views/caboose/users/edit_password.html.erb in caboose-cms-0.3.27

- old
+ new

@@ -1,34 +1,31 @@ <h1>Reset Password for <%= "#{@edituser.first_name} #{@edituser.last_name}" %></h1> +<form action='/admin/users/<%= @edituser.id %>' method='put' id='password_form'> +<input type='hidden' name='authenticity_token' value='<%= form_authenticity_token %>' /> <p><input type='password' name='password' id='password' value="" placeholder='Password' /></p> <p><input type='password' name='password2' id='password2' value="" placeholder='Confirm password' /></p> <div id='message'></div> -<div id='controls'> +<p> <input type='button' value='Back' onclick="window.location='/admin/users/<%= @edituser.id %>/edit';" /> -<input type='button' value='Update Password' onclick="updatePassword();" /> -</div> +<input type='button' value='Update Password' onclick="update_password();" /> +</p> <% content_for :caboose_js do %> <script type="text/javascript"> -var modal = false; -$(document).ready(function() { - modal = new CabooseModal(500); -}); -function updatePassword() +function update_password() { $.ajax({ - url: '/admin/users/update-password', - type: 'post', + url: '/admin/users/<%= @edituser.id %>', + type: 'put', + data: $('#password_form').serialize(), success: function(resp) { - if (resp.success) - modal.autosize("<p class='note success'>" + resp.success + "</p>"); - if (resp.error) - modal.autosize("<p class='note success'>" + resp.error + "</p>"); - if (resp.redirect) - window.location = resp.redirect; + if (resp.success) $('#message').html("<p class='note success'>The password has been reset.</p>"); + if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>"); + if (resp.redirect) window.location = resp.redirect; } }); } + </script> <% end %>