Tag: omn​​iauth

Omniauth Facebook重定向到注册屏幕而不是创建用户

按照gem的教程,我似乎仍然遇到了一些问题。 我首先点击链接通过Facebook注册并重定向到Facebook。 我点击没关系,然后回到我的注册页面。 没有创建新用户。 如果我再次尝试单击注册链接,则只需在地址栏中刷新页面http://localhost:3000/register#_=_ 。 我究竟做错了什么? 用户模型 devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable, omniauth_providers: [:facebook] def self.from_omniauth(auth) where(provider: auth.provider, uid: auth.uid).first_or_create do |user| user.email = auth.info.email user.password = Devise.friendly_token[0,20] user.first_name = auth.info.first_name user.last_name = auth.info.last_name end end 回调控制器 class Users::OmniauthCallbacksController :authentication #this will throw if @user is not activated set_flash_message(:notice, :success, :kind […]

Rails,Devise和Omniauth – 设置问题

我正在尝试(再次)使用Rails 4,devise和omniauth设置身份validation。 我试着按照这篇文章中的例子: Rails 4,Devise,Omniauth(有多个提供者) 我安装了这些gem: gem ‘devise’ gem ‘omniauth-google-oauth2’ gem ‘omniauth-facebook’ gem ‘omniauth-twitter’ gem ‘omniauth-linkedin-oauth2’ gem ‘oauth2′ 我有一个用户模型和一个身份validation模型。 我有: User.rb: has_many :authentications def disapprove self.approved = false end def approve self.approved = true end SOCIALS = {facebook:’Facebook’,google_oauth2:’Google’,linkedin:’Linkedin’} def self.from_omniauth(auth, current_user) authentication = Authentication.where(:provider => auth.provider, :uid => auth.uid.to_s, :token => auth.credentials.token, :secret => auth.credentials.secret).first_or_initialize […]

我正在使用rails cast omniauth,我收到此错误

我使用Mongodb作为rails中的数据库,使用/ auth / linkedin / callback时出错 AuthenticationsController#中的NoMethodError为nil创建未定义的方法[]’:NilClass Rails.root:/ home / prem / Music / heronhrm Application Trace | 框架跟踪| 完整跟踪app / models / user.rb:57:在apply_omniauth’app / controllers / authentications_controller.rb:19:在’create’中 当我删除self.email = omniauth[‘user_info’][’email’] if email.blank? 从usermodel然后出现validation错误 users / sign_up电子邮件不能为空我想为twitter,linkdin和facebook实现。 我的身份validation.rb class Authentication include Mongoid::Document belongs_to :user field :user_id, :type => String field :provider, :type => String field […]

如何使用Rails和minitest模拟OmniAuth哈希?

我正在使用Rails 5和minitest。 我想模拟登录我的会话控制器,它依赖于omniauth(我使用谷歌和FB登录)。 我在我的控制器test,test / controllers / rates_controller_test.rb中有这个, class RatesControllerTest < ActionDispatch::IntegrationTest # Login the user def setup logged_in_user = users(:one) login_with_user(logged_in_user) end 然后我尝试在我的测试助手test / test_helper.rb中设置登录, class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. fixtures :all def setup_omniauth_mock(user) OmniAuth.config.test_mode = true omniauth_hash = { ‘provider’ => ‘google’, ‘uid’ => […]

将随机url参数传递给OmniAuth

我正在使用omniauth和devise,我想知道如何传递url params并访问它们。 这是一个链接示例: /accounts/auth/facebook?do_something_after_return=1现在我希望能够在回调中检索此do_something_after_return 。 我不在乎它是否在会话或其他地方保存。 问题是,我不知道在哪里可以拦截这个参数。 什么是链接/accounts/auth/facebook指向的控制器和操作? 路线什么都没告诉我,它根本就不存在。 我在路线中的所有内容都是/accounts/auth/:provider(.:format {:controller=>”accounts/omniauth_callbacks”, :action=>”passthru”}这是一个回调。

为没有STI的多个模型设计Omniauth

有没有办法为没有STI的多个模型配置Devise Omniauth? 我们有模特学生和教授,我们不想使用STI,但现在我们意识到Devise with Omniauth不适合多种模式。 .rvm/gems/ruby-1.9.3-p125/gems/devise-2.1.0/lib/devise/rails/routes.rb:384:in `devise_omniauth_callback’: Wrong OmniAuth configuration. If you are getting this exception, it means that either: (RuntimeError) 1) You are manually setting OmniAuth.config.path_prefix and it doesn’t match the Devise one 2) You are setting :omniauthable in more than one model 3) You changed your Devise routes/OmniAuth setting and haven’t restarted your […]

设计 – 无法在rails视图中显示登录或注销

我正在使用设计来进行基本身份validation。 当我去localhost:3000/users/sign_in我将能够登录,或者当我登录时,如果我去那里,我将收到相应的消息“你已经登录了”。 但是, user_signed_in? 即使在成功登录后,也总是评估为假 Welcome ! :delete %> :delete %> “flash_#{name}” %> 这是config/application.rb class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_filter :authenticate_user! private def current_user @current_user ||= User.find(session[:user_id]) if session[:user_id] end helper_method :current_user end 我怎样才能获得user_signed_in? 是真实的? 无论我是否成功登录, current_user也仍然是假的

Facebook应用程序 – 通过omniauth登录 – OAuthException 191

我面临的问题是: “error”: { “message”: “Invalid redirect_uri: Given URL is not allowed by the Application configuration.”, “type”: “OAuthException”, “code”: 191 } 我在我的应用程序中设置了所需的密钥和令牌,在Facebook的开发中心我设置了Site URL:到http://127.0.0.1:3001我收到上面的错误。 此外,我尝试设置App Namespace:到http://127.0.0.1:3001 ,但我收到有关错误地址格式的错误…当我试图填写他的App Domain:并设置我的localhost,再次格式错误的错误…… 使用localhost的fabebook应用程序的正确配置是什么?

Rails 3路由约束和正则表达式

我希望匹配路径中的模式state/city ,除非状态变量等于“auth” match ‘/:state/:city’ => ‘cities#index’, :as => :state_cities, :constraints => {:state => /(?!auth)/ } 例如, mydomain.com/fl/miami很好。 mydomain.com/auth/twitter很糟糕。 我正在使用omniauth,它要求你去/auth/twitter进行身份validation,但是当我输入rake routes时无处可寻。

Devise,OmniAuth和Facebook:“没找到。 身份validationpassthru。“

试着跟随https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview ,我很难过。 我的config / initializers / devise.rb, devise_for :users, :controllers => { :omniauth_callbacks => “users/omniauth_callbacks” }在我的routes.rb中,并定义了一个OmniAuthCallbacks控制器。 当我访问user_omniauth_authorize_path(:facebook) ,我得到: Not found. Authentication passthru. Not found. Authentication passthru. 我不知道下一步该做什么。 我没有使用路由全球,所以我不认为我需要定义一个passthru方法,但这样做只给了我404。