have the ability now to update a row of direct deposit information as well as leverage the encryption routine to introduce a serious flaw
This commit is contained in:
@@ -4,8 +4,22 @@ class PayController < ApplicationController
|
||||
end
|
||||
|
||||
def update_dd_info
|
||||
msg = false
|
||||
pay = Pay.new(
|
||||
:bank_account_num => params[:bank_account_num],
|
||||
:bank_routing_num => params[:bank_routing_num],
|
||||
:percent_of_deposit => params[:dd_percent]
|
||||
)
|
||||
pay.user_id = current_user.user_id
|
||||
msg = true if pay.save!
|
||||
respond_to do |format|
|
||||
format.json {render :json => {:hello => :world} }
|
||||
format.json {render :json => {:msg => :world} }
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
respond_to do |format|
|
||||
format.json { render :json => {:user => current_user.pay.as_json} }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,25 @@
|
||||
class Pay < ActiveRecord::Base
|
||||
|
||||
# mass-assignable attributes
|
||||
attr_accessible :bank_account_num, :bank_routing_num, :percent_of_deposit
|
||||
|
||||
# Associations
|
||||
belongs_to :user
|
||||
|
||||
# Validations
|
||||
validates :bank_account_num, presence: true
|
||||
validates :bank_routing_num, presence: true
|
||||
validates :percent_of_deposit, presence: true
|
||||
|
||||
# actions
|
||||
before_save :encrypt_bank_account_num
|
||||
|
||||
def as_json
|
||||
super(only: [:bank_account_num, :bank_routing_num, :percent_of_deposit])
|
||||
end
|
||||
|
||||
def encrypt_bank_account_num
|
||||
self.bank_account_num = Encryption.encrypt_sensitive_value(self.bank_account_num)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -63,17 +63,23 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Row-Fluid for Inputs-->
|
||||
<!-- Begin Table Stuff -->
|
||||
|
||||
<!-- ###################-->
|
||||
<!-- Begin Dynamic Table ColSpan Table -->
|
||||
<div class="row-fluid">
|
||||
<div class="span9">
|
||||
<div class="widget no-margin">
|
||||
<div class="widget">
|
||||
|
||||
<!-- Begin Widget Header-->
|
||||
<div class="widget-header">
|
||||
<div class="title">
|
||||
<span class="fs1" aria-hidden="true" data-icon=""></span> Deletable Table Row
|
||||
<span class="fs1" aria-hidden="true" data-icon=""></span> Accounts
|
||||
</div>
|
||||
</div>
|
||||
<!-- End Widget Header-->
|
||||
<div class="widget-body">
|
||||
<table class="table table-striped table-bordered no-margin">
|
||||
<div id="dt_example" class="example_alt_pagination">
|
||||
<table class="table table-condensed table-striped table-hover table-bordered pull-left" id="data_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:25%">
|
||||
@@ -86,116 +92,86 @@
|
||||
Percentage of Deposit
|
||||
</th>
|
||||
<th style="width:25%">
|
||||
Actions
|
||||
Action
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td >
|
||||
1
|
||||
<!--<tr>
|
||||
<td>
|
||||
December
|
||||
</td>
|
||||
<td>
|
||||
Srinu
|
||||
14.7 %
|
||||
</td>
|
||||
<td class="hidden-phone">
|
||||
Active
|
||||
<td>
|
||||
31.1 %
|
||||
</td>
|
||||
<td class="hidden-phone">
|
||||
<td>
|
||||
<a class="delete-row" data-original-title="Delete" href="#">
|
||||
<i class="icon-trash">
|
||||
</i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
2
|
||||
</td>
|
||||
<td>
|
||||
Baswa
|
||||
</td>
|
||||
<td class="hidden-phone">
|
||||
Active
|
||||
</td>
|
||||
<td class="hidden-phone">
|
||||
<a class="delete-row" data-original-title="Delete" href="#">
|
||||
<i class="icon-trash">
|
||||
</i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
3
|
||||
</td>
|
||||
<td>
|
||||
Prem
|
||||
</td>
|
||||
<td class="hidden-phone">
|
||||
Inactive
|
||||
</td>
|
||||
<td class="hidden-phone">
|
||||
<a class="delete-row" data-original-title="Delete" href="#">
|
||||
<i class="icon-trash">
|
||||
</i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
4
|
||||
</td>
|
||||
<td>
|
||||
Arjun
|
||||
</td>
|
||||
<td class="hidden-phone">
|
||||
Active
|
||||
</td>
|
||||
<td class="hidden-phone">
|
||||
<a class="delete-row" data-original-title="Delete" href="#">
|
||||
<i class="icon-trash">
|
||||
</i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
5
|
||||
</td>
|
||||
<td>
|
||||
Gajju
|
||||
</td>
|
||||
<td class="hidden-phone">
|
||||
Inactive
|
||||
</td>
|
||||
<td class="hidden-phone">
|
||||
<a class="delete-row" data-original-title="Delete" href="#">
|
||||
<i class="icon-trash">
|
||||
</i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tr>-->
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="clearfix">
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- end of widget body-->
|
||||
</div>
|
||||
<!-- End Table Stuff-->
|
||||
</div>
|
||||
</div
|
||||
<!-- End Dynamic Table ColSpan Table -->
|
||||
<!-- ###################-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= javascript_include_tag "jquery.dataTables.js" %>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function parseDirectDepostInfo(response){
|
||||
var msg = jQuery.parseJSON(JSON.stringify(response));
|
||||
$.each(msg.user, function(index, val){
|
||||
$('#data_table').dataTable().fnAddData( [
|
||||
val.bank_account_num,
|
||||
val.bank_routing_num,
|
||||
val.percent_of_deposit,
|
||||
"test"
|
||||
] );
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
function populateTable() {
|
||||
$('#data_table').dataTable().fnClearTable();
|
||||
$.ajax({
|
||||
url: <%= sanitize(user_pay_path(:format => "json", :user_id => current_user.user_id, :id => current_user.user_id).inspect) %>,
|
||||
type: "GET",
|
||||
success: function(response) {
|
||||
parseDirectDepostInfo(response);
|
||||
},
|
||||
error: function(event) {
|
||||
$('#failure').show(500).delay(1500).fadeOut();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function createDataTable(){
|
||||
$('#data_table').dataTable({
|
||||
"sPaginationType": "full_numbers"
|
||||
});
|
||||
};
|
||||
|
||||
$('.delete-row').click(function () {
|
||||
var conf = confirm('Continue delete?');
|
||||
if (conf) $(this).parents('tr').fadeOut(function () {
|
||||
$(this).remove();
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$("#dd_form_btn").click(function(event) {
|
||||
var valuesToSubmit = $("#bank_info_form").serialize();
|
||||
@@ -206,6 +182,7 @@ $("#dd_form_btn").click(function(event) {
|
||||
type: "POST",
|
||||
success: function(response) {
|
||||
$('#success').show(500).delay(1500).fadeOut();
|
||||
populateTable();
|
||||
},
|
||||
error: function(event) {
|
||||
$('#failure').show(500).delay(1500).fadeOut();
|
||||
@@ -217,6 +194,10 @@ $("#dd_form_btn").click(function(event) {
|
||||
$('li[id="pay"]').addClass('active');
|
||||
};
|
||||
|
||||
$(document).ready(makeActive)
|
||||
$(document).ready(
|
||||
makeActive,
|
||||
createDataTable(),
|
||||
populateTable()
|
||||
)
|
||||
|
||||
</script>
|
||||
@@ -29,6 +29,9 @@ Railsgoat::Application.configure do
|
||||
# with SQLite, MySQL, and PostgreSQL)
|
||||
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
||||
|
||||
# Tired of caching causing issues
|
||||
config.middleware.delete Rack::ETag
|
||||
|
||||
# Do not compress assets
|
||||
config.assets.compress = false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user