设计:验证码不起作用

发布于 2024-11-07 16:05:29 字数 1592 浏览 2 评论 0原文

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

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

这是我的代码:

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

config/initializers/recaptcha.rb

Recaptcha.configure do |config|
    config.public_key  = 'mykey123456789'
    config.private_key = 'mykey13456789'
end

它可能不会无法工作,因为我处于测试模式而不是我的域名?

帮助将不胜感激!

my Devise Recaptcha isn't working correctly because I can skip right over it and still register.

I followed the Devise wiki at - https://github.com/plataformatec/devise/wiki/How-To:-Use-Recaptcha-with-Devise and got everything working accept i encountered the problem above.

Here is my code:

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

config/initializers/recaptcha.rb

Recaptcha.configure do |config|
    config.public_key  = 'mykey123456789'
    config.private_key = 'mykey13456789'
end

It is possible it doesn't work because i am in test mode and not on my domain name?

Help would be appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浮萍、无处依 2024-11-14 16:05:29

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

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

不在您的域名上可能会出现问题,具体取决于您注册密钥的方式。

In environment.rb put the following:

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

Not being on your domain name may be a problem depending on how you registered the keys.

还不是爱你 2024-11-14 16:05:29

这是一个没有安装 ImageMagick 或 RMagick 的问题,必须经历一些废话才能使其正常工作。

这些是我的考验和考验。磨难:

ImageMagick - “未找到 CORE_RL_magick_.dll”或如何使用 ruby​​ 1.9.2 在 Windows 上安装 RMagick

This was an issue with not having ImageMagick or RMagick installed, had to go through the nonsense to get this working.

These were my trials & tribulations:

ImageMagick - "CORE_RL_magick_.dll not found" or how to install RMagick on windows with ruby 1.9.2

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文