Devise: Edit account without need to confirm password

Asked

Viewed 320 times

1

Hello, this is my problem: I have an application (Rails 4) with the gem 'devise' and gem 'omniauth-facebook'. Who logs in with facebook at the time of editing the account appears error "Current password can’t be Blank'... In this way I would like to disable this password confirmation need if you edit the account. I know Vise has this tutorial on how to do this: Tutorial

But I don’t really understand what steps are necessary to do this, I’m new to programming, and the way I’m doing it is not working! Thank you!

  • 1

    Have you put your controller code?

  • You have yes Abbess, here is http://stackoverflow.com/questions/24463479/devise-update-account-without-password-confirmation !

  • Pasta. I’m also a beginner, but did you even try to put my suggestion below? I have it running in an application and it works perfectly. **Note: I only use Devise **

1 answer

0


I think you can do the following:

The method update Users controller could be like this:

def update
  if user_params[:password].blank?
   @user.update_without_password(user_params_without_password)
  else
   @user.update(user_params)
  end

 if @user.valid?
  if @user == current_user
    sing_in(@user, baypass: true)
  end
  redirect_to admin_users_url
 else
  render action: 'edit'
 end
end

Where that user_params_without_password is a private method:

def user_params_without_password
    user_params.delete(:password)
    user_params.delete(:password_confirmation)
    user_params
 end

And the update_without_password is a ready method of own Devise

Browser other questions tagged

You are not signed in. Login or sign up in order to post.