Commit fdf3dc0c by Hoang Nam Nguyen

'fixed forgot_page'

parent 5080eb67
......@@ -138,4 +138,8 @@ footer.page-footer {
.dark-grey-text {
color: #4f4f4f !important;
}
.font_footer {
font-size: 70%;
}
\ No newline at end of file
class AppliesController < ApplicationController
def new
@user_apply = Apply.new
end
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
def cofirm_apply
def confirm_apply
@user_apply = Apply.find(params[:id])
end
private
def user_apply
params.require(:apply).permit(:email, :name)
end
end
......@@ -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
......
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
......@@ -23,19 +23,15 @@ 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)
end
def send_password_reset_email
UserMailer.password_reset(self.id).deliver_later
self.reset_token = generate_token
update_attributes(:reset_digest => digest(reset_token))
update_attributes(:reset_sent_at => Time.zone.now)
end
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 +55,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
......
......@@ -11,6 +11,7 @@
</div>
<!--set field email -->
<div class="col-md-10">
<%= binding.pry %>
<%= @user_apply.email %>
</div>
<!--end field password -->
......@@ -46,7 +47,7 @@
<!--set button update -->
<div class="row ml-5 pb-5 pl-5">
<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
<% end %>
</div>
......
......@@ -42,15 +42,13 @@
</div>
<% end %>
<!--end set field all -->
<div class="row ">
<div class="col-sm-2"></div>
<div class="col-sm-10">
<%= button_tag(type: "submit", class: "btn btn-danger btn-block") do %>
<i class="fa fa-check 4px"></i> Confirm
<% end %>
</div>
</div>
<!--end set button -->
<!--end set button -->
<% end %>
</div>
</div>
......@@ -24,7 +24,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" href ="<%= form_apply_path(id: @job.id)%>">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">
......
......@@ -31,6 +31,7 @@ Rails.application.routes.draw do
resources :password_resets, only: [:new, :create, :edit, :update]
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'
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