Devise: Disable password confirmation during sign-up

后端 未结 9 1081
走了就别回头了
走了就别回头了 2020-12-24 01:13

I am using Devise for Rails. In the default registration process, Devise requires users to type the password twice for validation and authentication. How can I disable it?

9条回答
  •  清歌不尽
    2020-12-24 01:42

    For the sake of Rails 4 users who find this question, simply delete :password_confirmation from the permitted params, which you declare in ApplicationController.rb.

    before_filter :configure_permitted_parameters, if: :devise_controller?
    
    protected
    
    def configure_permitted_parameters
      devise_parameter_sanitizer.for(:sign_up) do |u|
        u.permit(:username, :email, :password)
      end
      devise_parameter_sanitizer.for(:account_update) do |u|
        u.permit(:username, :email, :password)
      end
    end
    

提交回复
热议问题