我正在将rails 3.2迁移到rails 4,我面临的设计问题无法验证我现有的用户已经更改了rails 4的更改,如下所示
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
在devise.rb
config.case_insensitive_keys = [ :email , :username ]
config.strip_whitespace_keys = [ :email , :username ]
设计3.0.4,bcrypt-ruby 3.1和rails 4,同时签署以下错误我正面临
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"}
如果我缺少任何配置,请告诉我。
谢谢
杰格迪什
答案 0 :(得分:0)
更改devise.rb
devise.rb
config.case_insensitive_keys = [ :username ]
config.strip_whitespace_keys = [ :username ]
答案 1 :(得分:0)
我在devise.rb中添加了这个问题解决了这个问题
config.authentication_keys = [:username]