내 프로젝트에는 구직자와 고용 관리자라는 두 가지 유형의 사용자가 있습니다. 구직자는 모델이 없으며 Omniauth를 통해 인증하는 동안 제 3 자 제공 업체로부터받은 데이터를 사용하여 작업을 신청할 수 있습니다. 고용 관리자 정보는 기기 사용자 모델에 저장됩니다. 채용 관리자는 회사의 Google 이메일 계정으로 로그인 할 수 있어야합니다.Devise omniauthable가 '경로에 대한 유효한 매핑을 찾을 수 없습니다.'와 함께 Omniauth 인증을 깨 웠습니다.
omniauth.rb
require 'omniauth-openid'
require 'openid/store/filesystem'
Rails.application.config.middleware.use OmniAuth::Builder do
provider :openid, :store => OpenID::Store::Filesystem.new('./tmp'), :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
provider :facebook, "xxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
{:scope => 'email, offline_access, publish_stream', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}
provider :twitter, "xxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxxxxx"
provider :linkedin, "xxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxx"
end
routes.rb
에 :
match '/auth/:provider/callback', :to => 'sessions#authenticate_jobseeker'
match '/auth/failure', :to => 'sessions#failure'
def authenticate_jobseeker
session[:jobseeker] = request.env['omniauth.auth']
if valid_job_seeker?
redirect_to new_job_application_path(...)
else
redirect_to request.env['omniauth.origin'] || root_path, alert: "Authentication failure"
end
end
sessions_controller.rb
에서 그래서 먼저 내가 3.1.3 레일, Omniauth 1.0.0 사용 구직자 '인증을 구축
까지이 시점까지 everythin g 잘 처리되었습니다. 그러나 사용자 모델에 대한 Google 로그인을 구현하기 시작했을 때 거기에 omniauthable을 추가하면 구직자 인증이 끊어졌습니다.
config.omniauth :open_id, :store => OpenID::Store::Filesystem.new('./tmp'), :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id', :require => 'omniauth-openid'
routes.rb
에 : devise.rb
에
user.rb
class User < ActiveRecord::Base
#...
devise :database_authenticatable, :registerable,
... :lockable, :omniauthable
#...
end
: 나는 고안 1.5.2을 사용하고
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } do
get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru'
end
이 시점에서, 사용자의 인증이 작동했지만 구직자들은하지 않았다. 잠시 동안 검색 한 후에 omniauth.rb
에있는 모든 공급자에게 :path_prefix => "/auth"
을 추가하여 문제가 해결되었습니다.
Could not find a valid mapping for path "/auth/twitter/callback"
Parameters:
{"denied"=>"mKjVfMRwRAN12ZxQ9cxCoD4rYSLJIRLnEqgiI"}
최고 : 구직자 (즉 프레스는 "허용 안 함"및 응용 프로그램에 다시 온다), 나는 모든 공급자에 대한 RuntimeError에 따라 얻을 데이터에 대한 액세스를 허용하지 않는 경우 이제 유일한 문제는, 추적의 :
devise (1.5.2) lib/devise/mapping.rb:48:in `find_by_path!'
devise (1.5.2) lib/devise/omniauth.rb:17:in `block in <top (required)>'
omniauth (1.0.0) lib/omniauth/strategy.rb:418:in `call'
omniauth (1.0.0) lib/omniauth/strategy.rb:418:in `fail!'
omniauth-oauth (1.0.0) lib/omniauth/strategies/oauth.rb:63:in `rescue in callback_phase'
omniauth-oauth (1.0.0) lib/omniauth/strategies/oauth.rb:45:in `callback_phase'
omniauth (1.0.0) lib/omniauth/strategy.rb:200:in `callback_call'
omniauth (1.0.0) lib/omniauth/strategy.rb:166:in `call!'
omniauth (1.0.0) lib/omniauth/strategy.rb:148:in `call'
omniauth (1.0.0) lib/omniauth/strategy.rb:168:in `call!'
omniauth (1.0.0) lib/omniauth/strategy.rb:148:in `call'
omniauth (1.0.0) lib/omniauth/strategy.rb:168:in `call!'
omniauth (1.0.0) lib/omniauth/strategy.rb:148:in `call'
omniauth (1.0.0) lib/omniauth/builder.rb:30:in `call'
나는 지금 당분간 그것을 해보기를 시도하고있다. 어떤 도움이라도 대단히 감사합니다. 추가 정보를 제공 할 수 있다면 알려주세요.
'omniauth [ "user_info"] [ "email"]'을 고려하십시오. 나는이'request.env [ "omniauth.auth"]'와 같은 인증 제공자로부터받은 auth_hash에 접근했다. 그리고 나서 나는 그것 [''info "] ["email "]'에 대해 이야기한다. 새로운 버전의 devis는'autn_hash.info [ 'email']'를 사용합니다. –