我现在用的是第三方收款软件,就是监控手机收款提示,然后,post 数据到我的服务器,我根据 post 回来的数据判断是否成功支付。
但是我现在碰到的问题是,post 到我的方法时,不带authenticity_token
,一直出现错误:Can't verify CSRF token authenticity
.
我的 post method:
class FundsController < ApplicationController
def success_recharge #method post
@r_user = User.find_by_id(params[:order_uid])
return_array = params[:aoid] +params[:order_id]+params[:order_uid]+params[:price]+params[:pay_price]+'1c9a3e0eba564d68831bbeefb2ae5f72' #第三方返回的数据
sign = make_md5_string(return_array)
if sign == params[:sign]
respond_to do |format|
format.html {
redirect_to funds_user_path(@r_user)
flash[:success] = "充值成功"
}
format.json{
render json: {status: :ok}
}
end
else
redirect_to funds_user_path(@r_user)
flash[:danger] = "充值失败,#{check_s[:status]}"
end
end
end
我的users_controller.rb
:
class UsersController < ApplicationController
before_action :logged_in_user
def funds
end
end
logged_in_user 方法:
module SessionsHelper
def logged_in_user
unless logged?
store_location
flash[:danger] = "请先登录"
redirect_to login_path
end
end
end
如果在FundsController
中添加skip_before_action :verify_authenticity_token, :only => [:success_recharge]
,那就不能redirect_to
到 funds_user_path(@r_user)
,而是到login_path
,
请问大家,我该怎么修改。非常感谢~~~!