Commit 192494b5 by Hoang Nam Nguyen

'fixed forgot_page'

parent 19d7354b
......@@ -10,7 +10,7 @@ class PasswordResetsController < ApplicationController
@user = User.find_by(email: params[:password_reset][:email].downcase)
if @user
@user.create_reset_digest
@user.send_password_reset_email
UserMailer.password_reset(@user.id).deliver_later
flash[:info] ="Email sent with password reset instructions"
redirect_to root_path
else
......
......@@ -27,8 +27,8 @@ class UsersController < ApplicationController
@user.validate_password = true
if @user.update_attributes(user_params)
@user.update_attribute(:activated, true)
@user.update_attribute(:activated_at, Time.zone.now)
@user.update_attributes(:activated => true)
@user.update_attributes(:activated_at => Time.zone.now)
flash[:success] = "Update success"
redirect_to my_page_path
else
......
......@@ -23,9 +23,9 @@ class User < ApplicationRecord
before_create :create_activation_digest
def create_reset_digest
self.reset_token = new_token
update_attribute(:reset_digest, digest(reset_token))
update_attribute(:reset_sent_at, Time.zone.now)
self.reset_token = generate_token
update_attributes(:reset_digest => digest(reset_token))
update_attributes(:reset_sent_at => Time.zone.now)
end
def send_password_reset_email
......@@ -35,7 +35,7 @@ class User < ApplicationRecord
def digest(string)
cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST :
BCrypt::Engine.cost
BCrypt::Password.create(string, cost: cost)
BCrypt::Password.create(string, cost: cost)
end
def set_password
......@@ -59,11 +59,11 @@ class User < ApplicationRecord
end
def create_activation_digest
self.activation_token = new_token
self.activation_token = generate_token
self.activation_digest = digest(activation_token)
end
def new_token
def generate_token
SecureRandom.urlsafe_base64
end
......
......@@ -20,7 +20,7 @@
<h4 class="card-title text-primary"><%= @job.company.company_name %></h4>
<p class="card-texts">Location: <%= @job.cities.map(&:location).join(',') %></p>
<p class="card-text"><a href="#">Salary: </a><%= @job.salary %></p>
<p class="card-text"><%= @job.descripton.gsub("\t"," ").gsub("\n","<br/>").gsub("\r","<br/>").html_safe %></p>
<%= simple_format(@job.descripton) %>
<a class="btn btn-success text-white w-25">Apply</a>
<a class="btn btn-success text-white w-25">Favorite</a>
</div>
......
......@@ -4,7 +4,7 @@
<div class="row ml-5">
<div class="col-md-10 col-md-offset-3">
<%= form_for(@user, url: password_reset_path(params.permit(:email, :id, :reset_digest))) do |f| %>
<%= render 'shared/error_messages'%>
<%= render 'shared/error_messages'%>
<div class="row mt-3">
<!--set field email -->
<div class="col-md-2 mb-5">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment