0

I am trying to insert a captcha in to my application's registration form. I need place a controller helper method to check whether the captcha is valid. I'm using OmniAuth-identity for my simple authentication, which does not provide a controller method. The user's registration form posts directly to the OmniAuth handler and so can't able to check the this helper method that is

if verify_recaptcha(:model => @post, :message => "Oh! It's error with reCAPTCHA!") && @post.save
    # ...
else
    # ...
end

Can anyone please help me on this how to place a controller helper method using OmniAuth-identity?

4

2 回答 2

0

The readme gives a hint on hooking up Omniauth-Identity lifecycle events to controller actions. Here's an example adapted to fit what your asking for:

# application.rb
use OmniAuth::Builder do
  provider :identity,
    :fields => [:email],
    :on_login => UsersController.action(:login)
end
于 2013-05-29T04:41:44.793 回答
0

这个公关会很有帮助。

例如:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :identity,  on_validation: lambda {|env| Captcha.valid_captcha?(env)}
end
于 2016-03-18T06:39:36.710 回答