Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question