K
K
kramidev2015-01-13 21:06:25
Ruby on Rails
kramidev, 2015-01-13 21:06:25

rails. Sorcery. How to encrypt crypted_password password from parameters?

I do authorization on sorcery. I did the registration, I am doing a password update, I want the old password to be entered first, I will compare it with the existing one and then update the new one. But how to encrypt the password?

def update
    @user = User.find(params[:id])
    if params[:password] == Sorcery::CryptoProviders::BCrypt::encrypt("secret", @user.salt)
      redirect_to root_path
    else
      render 'edit'
    end
    # if @user.update(users_params)
    #   redirect_to @user, notice: 'Парооль был успешно обновлен'
    # else
    #   render 'edit', alert: 'Обновить пароль не удалось'
    # end
  end

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
test4food, 2015-01-13
@test4food

@user.change_password!(new_password)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question