Commit 192494b5 by Hoang Nam Nguyen

'fixed forgot_page'

parent 19d7354b
...@@ -10,7 +10,7 @@ class PasswordResetsController < ApplicationController ...@@ -10,7 +10,7 @@ class PasswordResetsController < ApplicationController
@user = User.find_by(email: params[:password_reset][:email].downcase) @user = User.find_by(email: params[:password_reset][:email].downcase)
if @user if @user
@user.create_reset_digest @user.create_reset_digest
@user.send_password_reset_email UserMailer.password_reset(@user.id).deliver_later
flash[:info] ="Email sent with password reset instructions" flash[:info] ="Email sent with password reset instructions"
redirect_to root_path redirect_to root_path
else else
......
...@@ -27,8 +27,8 @@ class UsersController < ApplicationController ...@@ -27,8 +27,8 @@ class UsersController < ApplicationController
@user.validate_password = true @user.validate_password = true
if @user.update_attributes(user_params) if @user.update_attributes(user_params)
@user.update_attribute(:activated, true) @user.update_attributes(:activated => true)
@user.update_attribute(:activated_at, Time.zone.now) @user.update_attributes(:activated_at => Time.zone.now)
flash[:success] = "Update success" flash[:success] = "Update success"
redirect_to my_page_path redirect_to my_page_path
else else
......
...@@ -23,9 +23,9 @@ class User < ApplicationRecord ...@@ -23,9 +23,9 @@ class User < ApplicationRecord
before_create :create_activation_digest before_create :create_activation_digest
def create_reset_digest def create_reset_digest
self.reset_token = new_token self.reset_token = generate_token
update_attribute(:reset_digest, digest(reset_token)) update_attributes(:reset_digest => digest(reset_token))
update_attribute(:reset_sent_at, Time.zone.now) update_attributes(:reset_sent_at => Time.zone.now)
end end
def send_password_reset_email def send_password_reset_email
...@@ -35,7 +35,7 @@ class User < ApplicationRecord ...@@ -35,7 +35,7 @@ class User < ApplicationRecord
def digest(string) def digest(string)
cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST :
BCrypt::Engine.cost BCrypt::Engine.cost
BCrypt::Password.create(string, cost: cost) BCrypt::Password.create(string, cost: cost)
end end
def set_password def set_password
...@@ -59,11 +59,11 @@ class User < ApplicationRecord ...@@ -59,11 +59,11 @@ class User < ApplicationRecord
end end
def create_activation_digest def create_activation_digest
self.activation_token = new_token self.activation_token = generate_token
self.activation_digest = digest(activation_token) self.activation_digest = digest(activation_token)
end end
def new_token def generate_token
SecureRandom.urlsafe_base64 SecureRandom.urlsafe_base64
end end
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<h4 class="card-title text-primary"><%= @job.company.company_name %></h4> <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-texts">Location: <%= @job.cities.map(&:location).join(',') %></p>
<p class="card-text"><a href="#">Salary: </a><%= @job.salary %></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">Apply</a>
<a class="btn btn-success text-white w-25">Favorite</a> <a class="btn btn-success text-white w-25">Favorite</a>
</div> </div>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<div class="row ml-5"> <div class="row ml-5">
<div class="col-md-10 col-md-offset-3"> <div class="col-md-10 col-md-offset-3">
<%= form_for(@user, url: password_reset_path(params.permit(:email, :id, :reset_digest))) do |f| %> <%= 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"> <div class="row mt-3">
<!--set field email --> <!--set field email -->
<div class="col-md-2 mb-5"> <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