通过设计基于其他参数登录

时间:2019-02-24 09:52:14

标签: ruby-on-rails devise

我的客户希望将用户分为普通用户和第三方用户。这意味着表中的用户可能有两条记录具有相同的电子邮件,但在is_party_user中具有不同的值(普通用户= false,反之亦然)。

我尝试解决此instruction

的问题

但是它不起作用(ActionDispatch :: Request:0x00000007619250的未定义方法“ is_party_user”)

有没有一种方法可以识别然后在SessionController#create中进行身份验证的用户类型?

在具有附加参数的第三个用户的登录参数中:is_party_user = true

user.rb

devise :database_authenticatable, :encryptable, :registerable,
     :validatable, :recoverable, :rememberable, :trackable, :lockable,
     :timeoutable, :omniauthable, request_keys: [:is_party_user]

def self.find_first_by_auth_conditions warden_conditions
    where(:email => warden_conditions[:email], :is_party_user => warden_conditions[:is_party_user]).first
  end

在self.resource = warden.authenticate!(auth_options)(SessionController#creat)上给我一个错误

undefined method `is_party_user' for #<ActionDispatch::Request:0x00000008def2a8>

参数

{"utf8"=>"✓", "authenticity_token"=>"xxxxxxxx", "user"=>{"is_party_user"=>"1", "email"=>"user@abc", "password"=>"1234"}}

0 个答案:

没有答案
相关问题