gpt4 book ai didi

ruby-on-rails - 设计:Recaptcha 不起作用

转载 作者:行者123 更新时间:2023-12-02 04:09:19 26 4
gpt4 key购买 nike

我的 Devise Recaptcha 无法正常工作,因为 我可以直接跳过它并仍然注册

我在 - https://github.com/plataformatec/devise/wiki/How-To:-Use-Recaptcha-with-Devise 关注了 Devise wiki,一切正常,我遇到了上述问题。

这是我的代码:

app/controllers/users/registrations.rb

class Users::RegistrationsController < Devise::RegistrationsController
def create
if verify_recaptcha
super
else
build_resource
clean_up_passwords(resource)
flash[:alert] = "There was an error with the recaptcha code below. Please re-enter the code and click submit."
render_with_scope :new
end
end
end

routes.rb
YourApp::Application.routes.draw do

devise_for :users do
root :to => "devise/registrations#new"
get "/" => "devise/registrations#new"
post '/' => 'registrations#new', :as => :new_user_registration
match '/', :to => 'devise/registrations#new'
.
.
.
.
.
end

devise_for :users, :controllers => { :registrations => "users/registrations" }

namespace :user do
root :to => "home#index"
end

配置/初始化程序/recaptcha.rb
Recaptcha.configure do |config|
config.public_key = 'mykey123456789'
config.private_key = 'mykey13456789'
end

它可能不起作用,因为我处于测试模式而不是我的域名?

帮助将不胜感激!

最佳答案

在 environment.rb 中放入以下内容:

ENV['RECAPTCHA_PUBLIC_KEY']  = 'mykey123456789'
ENV['RECAPTCHA_PRIVATE_KEY'] = 'mykey123456789'

根据您注册 key 的方式,不在您的域名上可能是个问题。

关于ruby-on-rails - 设计:Recaptcha 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6035295/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com