简体   繁体   中英

rails 4 devise not matching password

I am migrating rails 3.2 to rails 4 where I am facing issue of devise not able to authenticate my existing user have changed the rails 4 changes as below

 before_action :configure_permitted_parameters, if: :devise_controller?

    def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :password_confirmation, :remember_me) }
    devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :username, :email, :password, :remember_me) }
    devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :password_confirmation, :current_password) }
  end

In devise.rb

config.case_insensitive_keys = [ :email , :username ]
config.strip_whitespace_keys = [ :email , :username ]

devise 3.0.4, bcrypt-ruby 3.1 and rails 4 while signing the below error I am facing

  Processing by Devise::SessionsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"yEQsn0cRdMdHvh5HYFvLyjIoW7G85X+sujK0iHS73SQ=", "user"=>{"username"=>"tony_test", "password"=>"[FILTERED]"}, "commit"=>"Sign in"}
Completed 401 Unauthorized in 3ms
Processing by Devise::SessionsController#new as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"yEQsn0cRdMdHvh5HYFvLyjIoW7G85X+sujK0iHS73SQ=", "user"=>{"username"=>"tony_test", "password"=>"[FILTERED]"}, "commit"=>"Sign in"}

Please let me know if any configuration I am missing.

Thank you

Jagdish

Change the devise.rb

devise.rb

config.case_insensitive_keys = [ :username ]
config.strip_whitespace_keys = [ :username ]

我通过在devise.rb中添加它解决了这个问题

config.authentication_keys = [:username]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM