Commit fdf3dc0c by Hoang Nam Nguyen

'fixed forgot_page'

parent 5080eb67
...@@ -138,4 +138,8 @@ footer.page-footer { ...@@ -138,4 +138,8 @@ footer.page-footer {
.dark-grey-text { .dark-grey-text {
color: #4f4f4f !important; color: #4f4f4f !important;
}
.font_footer {
font-size: 70%;
} }
\ No newline at end of file
class AppliesController < ApplicationController class AppliesController < ApplicationController
def new def new
@user_apply = Apply.new @user_apply = Apply.new
end end
def create def create
if return current_user.nil? return if current_user.nil?
@user_apply = Apply.new(user_apply)
if @user_apply.save
redirect_to confirm_apply_path(id: @user_apply.id)
else
render 'new'
end end
end end
def cofirm_apply def confirm_apply
@user_apply = Apply.find(params[:id])
end end
private
def user_apply
params.require(:apply).permit(:email, :name)
end
end end
...@@ -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
......
class Apply < ApplicationRecord class Apply < ApplicationRecord
validates :name, presence: true, length: {maximum: 200}
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, length: {maximum: 255},
format: {with: VALID_EMAIL_REGEX}
end end
...@@ -23,19 +23,15 @@ class User < ApplicationRecord ...@@ -23,19 +23,15 @@ 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
def send_password_reset_email
UserMailer.password_reset(self.id).deliver_later
end end
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 +55,11 @@ class User < ApplicationRecord ...@@ -59,11 +55,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
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
</div> </div>
<!--set field email --> <!--set field email -->
<div class="col-md-10"> <div class="col-md-10">
<%= binding.pry %>
<%= @user_apply.email %> <%= @user_apply.email %>
</div> </div>
<!--end field password --> <!--end field password -->
...@@ -46,7 +47,7 @@ ...@@ -46,7 +47,7 @@
<!--set button update --> <!--set button update -->
<div class="row ml-5 pb-5 pl-5"> <div class="row ml-5 pb-5 pl-5">
<div class="col-md-4 text-center "> <div class="col-md-4 text-center ">
<%= link_to edit_user_path,class: 'btn btn-danger' do %> <%= link_to '#',class: 'btn btn-danger' do %>
<i class="fa fa-wrench"></i> Edit <i class="fa fa-wrench"></i> Edit
<% end %> <% end %>
</div> </div>
......
...@@ -42,15 +42,13 @@ ...@@ -42,15 +42,13 @@
</div> </div>
<% end %> <% end %>
<!--end set field all --> <!--end set field all -->
<div class="row ">
<div class="col-sm-2"></div> <div class="col-sm-2"></div>
<div class="col-sm-10"> <div class="col-sm-10">
<%= button_tag(type: "submit", class: "btn btn-danger btn-block") do %> <%= button_tag(type: "submit", class: "btn btn-danger btn-block") do %>
<i class="fa fa-check 4px"></i> Confirm <i class="fa fa-check 4px"></i> Confirm
<% end %> <% end %>
</div> </div>
</div> <!--end set button -->
<!--end set button -->
<% end %> <% end %>
</div> </div>
</div> </div>
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,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" href ="<%= form_apply_path(id: @job.id)%>">Apply</a> <a class="btn btn-success text-white w-25" href ="<%= form_apply_path(id: @job.id)%>">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">
......
...@@ -31,6 +31,7 @@ Rails.application.routes.draw do ...@@ -31,6 +31,7 @@ Rails.application.routes.draw do
resources :password_resets, only: [:new, :create, :edit, :update] resources :password_resets, only: [:new, :create, :edit, :update]
get 'apply/job/:id',controller: :applies,action: :new,as: :form_apply get 'apply/job/:id',controller: :applies,action: :new,as: :form_apply
post 'apply/job/:id',controller: :applies,action: :create post 'apply/job/:id',controller: :applies,action: :create,as: :new_info
get 'confirm/:id', controller: :applies,action: :confirm_apply,as: :confirm_apply
mount Sidekiq::Web => '/sidekiq' mount Sidekiq::Web => '/sidekiq'
end end
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