Hello im using my rails app to access an existing project with a database that cannot be changed. So my question is how can i create a session using Bcrypt without the need of haveing the column password_digest in my DB?, I already have stored in my DB the password in the column password.
Here is my code
def create
user = User.find_by(email: params[:session][:email].downcase)
# user.update_attribute(:last_login, DateTime.now)
if user && user.authenticate(params[:session][:password])
log_in user
flash[:success] = "Bienvenido de nuevo #{current_user.name.upcase}"
redirect_to user
else
flash[:danger] = 'Email invalido/Contrasena incorrecta' # Not quite right!
render 'new'
end
end
Aucun commentaire:
Enregistrer un commentaire