Add client identification methods
This commit is contained in:
parent
1233431d14
commit
7423cb4dda
3 changed files with 15 additions and 2 deletions
|
@ -6,4 +6,15 @@ class ApplicationController < ActionController::Base
|
||||||
rescue_from CanCan::AccessDenied do |exception|
|
rescue_from CanCan::AccessDenied do |exception|
|
||||||
redirect_to root_url, alert: exception.message
|
redirect_to root_url, alert: exception.message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def current_client
|
||||||
|
@current_client ||= identify_client
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def identify_client
|
||||||
|
key = request.headers["X-API-KEY"]
|
||||||
|
Client.find_by key: key if key
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class TransactionsController < ApplicationController
|
class TransactionsController < ApplicationController
|
||||||
|
skip_before_filter :verify_authenticity_token, :only => :create
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@transactions = Transaction.all
|
@transactions = Transaction.all
|
||||||
|
@ -9,7 +10,8 @@ class TransactionsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@transaction = current_user.outgoing_transactions.build transaction_params.merge(origin: I18n.t('origin.created_by_user'))
|
@transaction = current_user.outgoing_transactions.build(
|
||||||
|
transaction_params.merge(origin: I18n.t('origin.created_by_user'))
|
||||||
|
|
||||||
if @transaction.save
|
if @transaction.save
|
||||||
redirect_to current_user
|
redirect_to current_user
|
||||||
|
|
|
@ -2,7 +2,7 @@ class TransactionDatatable < AjaxDatatablesRails::Base
|
||||||
include TransactionsHelper
|
include TransactionsHelper
|
||||||
|
|
||||||
def sortable_columns
|
def sortable_columns
|
||||||
@sortable_columns ||= ['Transaction.amount']
|
@sortable_columns ||= ['Transaction.created_at']
|
||||||
end
|
end
|
||||||
|
|
||||||
def searchable_columns
|
def searchable_columns
|
||||||
|
|
Loading…
Reference in a new issue