Делаю авторизацию Devise+Omniauth+google+facebook+vk. Все работает кроме гема omniauth-vkontakte при нажатие не происходит авторизация а кидает на domain/users/sign_up в чем может быть ошибка?
app/models/user.rb
devise :omniauthable, :omniauth_providers => [:google_oauth2, :facebook, :vkontakte]
def self.find_for_vkontakte_oauth(auth, signed_in_resource=nil)
user = User.where(:provider => auth.provider, :uid => auth.uid).first
if user
return user
else
registered_user = User.where(:email => auth.info.email).first
if registered_user
return registered_user
else
user = User.create(name:auth.extra.raw_info.name,
provider:auth.provider,
uid:auth.uid,
email:auth.info.email,
password:Devise.friendly_token[0,20],
)
end end
end
app/controllers/users/omniauth_callbacks_controller.rb
def vkontakte
@user = User.find_for_vkontakte_oauth(request.env["omniauth.auth"], current_user)
if @user.persisted?
set_flash_message(:notice, :success, :kind => "Vkontakte") if is_navigational_format?
sign_in_and_redirect @user, :event => :authentication
else
session["devise.vkontakte_data"] = request.env["omniauth.auth"].except("extra")
redirect_to new_user_registration_url
end
end
config/initializers/devise.rb
config.omniauth :vkontakte, "546546545", "fdgnG1fdgxgVefdgO",
{
:scope => 'friends,audio,photos',
:display => 'popup',
:lang => 'en',
:image_size => 'original'
}