如何在我的网站上验证从另一个网站发送的查询字符串

时间:2019-11-24 11:34:06

标签: ruby-on-rails ruby-on-rails-5

我有一个连接到API的网站,该网站要求我生成参考代码以及我需要完成注册的其他信息。确认注册后,服务器将以重定向到我的控制器操作的方式响应,以完成整个过程,在此我必须通过另一个控制器操作进行验证。但是,我已经尝试了以下方法,但是仍然难以使我的网站响应重定向,即:显示消息“书已确认!”

Here is the url i get: 
  http/example.com/?ref=2755558333388=referencecode=2755558333388
instead of        
  http/example.com/book?ref=2755558333388=referencecode=2755558333388



# route
Rails.application.routes.draw do
   get 'confirmations/register'
   post 'confirmations/verified'
end


# controller:

class ConfirmationsController < ApplicationController
  def register
    registerationObj = Registration.new(ENV["BOOKREG_PUBLIC_KEY"], ENV["BOOKREG_PRIVATE_KEY"])
    book = RegistrationBooks.new(registrationObj)
    :action = books.create(
        :book_title => @book.title,
        :phone => current_user.phone,
        :email => current_user.email,
        :referencecode => @book.referencecode
  end

  def verified
    if params[:referencecode == @book.referencecode
      flash[:alert] = "Your book has been verified"
      redirect_to books_path
    else
      redirect_to current_user_edit_path, notice: "Sorry your book was not verified"
    end
  end

0 个答案:

没有答案