RoR Devise: Sign in with username OR email

前端 未结 11 2725
渐次进展
渐次进展 2020-12-07 10:15

What\'s the best way to enable users to log in with their email address OR their username? I am using warden + devise for authentication. I think it probably won\'t be too h

11条回答
  •  忘掉有多难
    2020-12-07 10:53

    def self.find_for_authentication(conditions)
      conditions = ["username = ? or email = ?", conditions[authentication_keys.first], conditions[authentication_keys.first]]
      # raise StandardError, conditions.inspect
      super
    end
    

    Use their example!

提交回复
热议问题