X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=blobdiff_plain;f=app%2Fcontrollers%2Fapplication_controller.rb;fp=app%2Fcontrollers%2Fapplication_controller.rb;h=57214ee59f59ac4e46125a802a8186829808124c;hp=634b9c38397d09f2bbfdfc35957bbefe305b0342;hb=c5fdcefa82de4c0b3bf5a69b6ec120827542a875;hpb=d2a17869f5a5fb9a33ddad29887c8f03a129c407 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 634b9c38..57214ee5 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,7 +3,7 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :null_session, if: Proc.new {|c| c.request.format == 'application/json'} layout :devise_layout before_action :bf - before_action :authenticate_user_from_token!, if: -> {params[:email].present?} + before_action :authenticate_user_from_token!, if: -> {params[:email].present? or request.headers[:email]} def devise_layout if devise_controller? @@ -54,8 +54,8 @@ class ApplicationController < ActionController::Base end def authenticate_user_from_token! - user = User.find_by(email: params[:email]) - if Devise.secure_compare(user.try(:authentication_token), params[:auth_token]) + user = User.find_by(email: (params[:email] or request.headers[:email])) + if Devise.secure_compare(user.try(:authentication_token), (params[:token] or request.headers[:token])) sign_in user, store: false self.bf end @@ -150,7 +150,7 @@ class ApplicationController < ActionController::Base res = { :page_status => { :type => :default, :total => @finder.total_count, :total_page => @finder.total_pages, - :page => @finder.page, :page_size => @finder.limit_value, + :page => @finder.current_page, :page_size => @finder.limit_value, :item_name => @my_action.return_item_name }, # rails3.2 has problem @@ -160,6 +160,7 @@ class ApplicationController < ActionController::Base :list => list.map{|i| i.attributes} # :list => @finder.to_json } + p res render json: res.to_json } end