Rails 3 - Devise : How to skip the 'current_password' when editing a registration?

前端 未结 5 2012
无人共我
无人共我 2021-01-30 18:53

I\'ve implemented omniauth with my devise model, so I can authenticate using other services. Password is not necessary anymore for my model, as users can authenticate using twit

5条回答
  •  旧时难觅i
    2021-01-30 19:20

    As of devise v4.6.2. It is very easy to do.

    As documentation said here:

    By default we want to require a password checks on update. You can overwrite this method in your own RegistrationsController.

    It means, in your controller override the method update_resource to replace update_with_password with update_without_password:

    class Users::RegistrationsController < Devise::RegistrationsController
    
      # ...
    
      protected
    
      def update_resource(resource, params)
        resource.update_without_password(params)
      end
    end
    

提交回复
热议问题