Reputation: 83
I have Rails 3.0.9 app, in my sessions_controller I have
def open_id_authentication(domain=nil)
domain = "" if domain.nil?
complete_identity_url = IDENTITY_URL + domain
authenticate_with_open_id(complete_identity_url, OPENID_OPTS) do |openid_result, identity_url, registration|
if openid_result.successful?
matches = /\/a\/(.*)\/o8/.match(params["openid.op_endpoint"])
google_domain = matches[1] if matches[1]
if valid_account?(google_domain)
account = Account.find_by_google_domain(google_domain)
session[:account_id] = account.id
self.current_user = User.openid_registration(registration, identity_url, account.id)
else
flash[:error] = t('flash.session.domain_not_registered')
redirect_to accounts_path
return false
end
redirect_back_or_default(THIS_path)
else
flash[:error] = t('flash.open_id.authentication_failed')
redirect_to accounts_path
end
end
end
Gemfile
gem 'ruby-openid', '2.1.8'
gem 'ruby-openid-apps-discovery', '1.2.0'
gem 'open_id_authentication', '1.0.0'
I'm getting error in row
matches = /\/a\/(.*)\/o8/.match(params["openid.op_endpoint"])
because params doesn't contain such key.
Before, the app was Rails 2.3.14 and three listed gems were plugins. It worked fine. Someone have issued such thing, help please.
Thanks!
Upvotes: 1
Views: 170
Reputation: 83
I solved that by replacing
matches = /\/a\/(.*)\/o8/.match(params["openid.op_endpoint"])
by
matches = /\/a\/(.*)\/o8/.match(request.env[Rack::OpenID::RESPONSE].endpoint.server_url)
Upvotes: 1