Commit 0921c4b8 by Mai Hoang Thai Ha

fixed Forgot password, new password, login page, profile, edit infomation

parent 60268529
......@@ -69,91 +69,3 @@ footer {
// search
// latest-job
.latest-job {
.job-item {
font-size: 14px;
.job-title {
text-decoration: none;
color: black;
font-size: 20px;
font-weight: 500;
}
.job-caption {
line-height: 18px;
.job-company {
text-decoration: none;
font-size: 14px;
color: $gray-700;
}
.job-salary {
color: #008563;
margin: 0;
}
.job-locations {
ul {
list-style: none;
margin: 0 0 6px 0;
padding: 0;
color: $gray-700;
}
}
.job-desc {
overflow: hidden;
text-overflow: ellipsis;
line-height: 18px;
-webkit-line-clamp: 2;
max-height: 36px;
display: -webkit-box;
-webkit-box-orient: vertical;
}
}
}
}
// top_cities
.top_cities {
.city-item {
margin-bottom: 12px;
a {
font-size: 18px;
text-decoration: none;
color: #287ab9;
margin: 10px 0;
}
}
.all-cities-btn {
color: #287ab9;
font-size: 20px;
text-decoration: none;
}
.all-cities-btn:hover {
text-decoration: underline;
}
}
// top_industries
.top_industries {
.industry-item {
margin-bottom: 12px;
a {
font-size: 18px;
text-decoration: none;
color: #287ab9;
margin: 10px 0;
}
}
.all-industries-btn {
color: #287ab9;
font-size: 20px;
text-decoration: none;
}
.all-industries-btn:hover {
text-decoration: underline;
}
}
// cities list
......@@ -54,10 +54,6 @@ class AppliesController < ApplicationController
params.require(:apply_job).permit(:user_name, :email, :cv, :job_id)
end
def current_user
@current_user ||= User.first
end
def use_apply_job_session?
request.referer&.include?('confirm') && session[:apply_job].present?
end
......
class UsersController < ApplicationController
before_action :logged_in_user
# before_action :logged_in_user
def show
@user = User.find(params[:id])
@user = current_user
end
end
......@@ -78,21 +78,39 @@ Validator = function(options) {
}
}
Validator.isRequired = function (selector) {
Validator.isRequired = function (selector, message) {
return {
selector: selector,
test: function (value) {
return value.trim() ? undefined : "This field can't be blank"
return value.trim() ? undefined : message || "This field can't be blank"
}
}
}
Validator.isEmail = function (selector) {
Validator.isEmail = function (selector, message) {
return {
selector: selector,
test: function (value) {
var regex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return regex.test(value) ? undefined : 'Email invalid';
return regex.test(value) ? undefined : message || 'Email invalid';
}
}
}
Validator.minLenght = function (selector, min, message) {
return {
selector: selector,
test: function (value) {
return value.length >= min ? undefined : message || 'field too short';
}
}
}
Validator.isConfirmed = function (selector, getConfirmValue, message) {
return {
selector: selector,
test: function (value) {
return value == getConfirmValue() ? undefined : message || 'Incorrect password';
}
}
}
......
......@@ -6,11 +6,11 @@ header.navbar.navbar-fixed-top.navbar-inverse
ul.nav.navbar-nav.navbar-right.text-light
- if user_signed_in?
li
= link_to "Profile", current_user
= link_to "Profile", user_profile_path
li
= link_to "Log out", destroy_user_session_path, method: :delete
- else
li
= link_to "Log in", new_user_session_path
= link_to "Log in", login_path
li
= link_to "Sign up", new_user_registration_path
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
p
| Dear #{@resource.email}!
p You have a new password!
p Your password for signing in to VenJOB was recently changed. If you made this change, then we're all set.
p= link_to 'Change my password', reset_password_url(reset_password_token: @token)
p If you did not make this change, please reset your password to secure your account. Then reply to this email to notify us.
p Either way, feel free to reach out with any questions you might have. We're here to help.
p Best
\ No newline at end of file
- provide(:title, "Change password")
- provide(:title, 'Change password')
.container
.row.justify-content-center
......@@ -6,20 +6,33 @@
h2.text-center.my-5
| Change your password
= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f|
= render "users/shared/error_messages", resource: resource
= render 'users/shared/error_messages', resource: resource
= f.hidden_field :reset_password_token
.field
= f.label :password, "New password", class: 'form-label'
br/
- if @minimum_password_length
em
| (#{@minimum_password_length} characters minimum)
br/
= f.password_field :password, autofocus: true, autocomplete: "new-password", class: 'form-control mb-2'
.field
= f.label :password_confirmation, "Confirm new password", class: 'form-label'
br/
= f.password_field :password_confirmation, autocomplete: "new-password", class: 'form-control mb-2'
.actions
= f.submit "Change my password", class: 'btn btn-primary w-100 my-4'
= render "users/shared/links"
.field.row.mb-5.form-group
.col-4
= f.label :password, 'New password', class: 'form-label'
.col-8
= f.password_field :password, autofocus: true, autocomplete: 'new-password', class: 'form-control mb-2'
span.form-msg
.field.row.mb-5.form-group
.col-4
= f.label :password_confirmation, 'Password Confirmation', class: 'form-label'
.col-8
= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control mb-2'
span.form-msg
.actions.row.justify-content-end
.col-8
= f.submit 'Change my password', class: 'btn btn-primary w-50 my-4', data: { disable_with: false }
javascript:
Validator({
form: '#new_user',
errorSelector: '.form-msg',
rules: [
Validator.isRequired('#user_password'),
Validator.minLenght('#user_password', 6, 'Use 6 characters or more for your password'),
Validator.isRequired('#user_password_confirmation'),
Validator.isConfirmed('#user_password_confirmation', function() {
return document.querySelector('#new_user #user_password').value;
}, 'Those passwords didn’t match.'),
]
})
- provide(:title, "Forgot password")
- provide(:title, 'Forgot password')
.container
.row.justify-content-center
.col-6
h2.text-center.my-5
| Forgot your password?
| Forgot password
= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f|
= render "users/shared/error_messages", resource: resource
.field
= render 'users/shared/error_messages', resource: resource
.field.row.form-group.mb-4
.col-2
= f.label :email, class: 'form-label'
br/
= f.email_field :email, autofocus: true, autocomplete: "email", class: 'form-control mb-2'
.actions
= f.submit "Send me reset password instructions", class: 'btn btn-primary w-100 my-4'
= render "users/shared/links"
.col-10
= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control mb-2'
span.form-msg
.actions.row.justify-content-end
.col-10.d-flex.justify-content-center
= f.submit 'Confirm your email', class: 'btn btn-primary w-75 my-4', data: { disable_with: false }
javascript:
Validator({
form: '#new_user',
errorSelector: '.form-msg',
rules: [
Validator.isRequired('#user_email'),
Validator.isEmail('#user_email')
]
})
- provide(:title, "Edit profile")
- provide(:title, 'Edit profile')
.container
.row.justify-content-center
.col-6
.col-8
h2.text-center.my-5
| Edit
= resource_name.to_s.humanize
= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f|
= render "users/shared/error_messages", resource: resource
.field
= render 'users/shared/error_messages', resource: resource
.field.row.mb-2.form-group
.col-3
= f.label :email, class: 'form-label'
br
= f.email_field :email, autofocus: true, autocomplete: "email", class: 'form-control mb-2'
.field
.col-9
= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control mb-2'
span.form-msg
.field.row.mb-2.form-group
- if devise_mapping.confirmable? && resource.pending_reconfirmation?
div
| Currently waiting confirmation for:
= resource.unconfirmed_email
.field
.field.row.mb-2.form-group
.col-3
= f.label :name, class: 'form-label'
br
= f.text_field :name, autofocus: true, autocomplete: "name", class: 'form-control mb-2'
.field
.col-9
= f.text_field :name, autofocus: true, autocomplete: 'name', class: 'form-control mb-2'
span.form-msg
.field.row.mb-2.form-group
.col-3
= f.label :address, class: 'form-label'
br
= f.text_field :address, autofocus: true, autocomplete: "address", class: 'form-control mb-2'
.field
.col-9
= f.text_field :address, autofocus: true, autocomplete: 'address', class: 'form-control mb-2'
span.form-msg
.field.row.mb-2.form-group
.col-3
= f.label :phone, class: 'form-label'
br
= f.text_field :phone, autofocus: true, autocomplete: "phone", class: 'form-control mb-2'
.field
.col-9
= f.text_field :phone, autofocus: true, autocomplete: 'phone', class: 'form-control mb-2'
span.form-msg
.row.my-4.justify-content-end
.col-9
hr
p
|(leave password blank if you don't want to change it)
.field.row.mb-2.form-group
.col-3
= f.label :password, class: 'form-label'
i
| (leave blank if you don't want to change it)
br
= f.password_field :password, autocomplete: "new-password", class: 'form-control mb-2'
- if @minimum_password_length
em
= @minimum_password_length
| characters minimum
.field
.col-9
= f.password_field :password, autocomplete: 'new-password', class: 'form-control mb-2'
span.form-msg
.field.row.mb-2.form-group
.col-3
= f.label :password_confirmation, class: 'form-label'
br
= f.password_field :password_confirmation, autocomplete: "new-password", class: 'form-control mb-2'
.field
.col-9
= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control mb-2'
span.form-msg
.field.row.mb-2.form-group
.col-3
= f.label :current_password, class: 'form-label'
i
| (we need your current password to confirm your changes)
br
= f.password_field :current_password, autocomplete: "current-password", class: 'form-control mb-2'
.actions
= f.submit "Done", class: "btn btn-primary w-100 my-4"
.col-9
= f.password_field :current_password, autocomplete: 'current-password', class: 'form-control mb-2'
span.form-msg
.actions.row.justify-content-end
.col-9
= f.submit 'Done', class: 'btn btn-primary w-50 my-4', data: { disable_with: false }
hr
h3
| Delete my account
p
| Click the button below to delete account
= button_to "Delete", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete, class: "btn btn-primary w-100 my-4"
= link_to "Home", :back
\ No newline at end of file
= button_to 'Delete', registration_path(resource_name), data: { confirm: 'Are you sure?' }, method: :delete, class: 'btn btn-primary w-100 my-4'
= link_to 'Home', :back
javascript:
Validator({
form: '#edit_user',
errorSelector: '.form-msg',
rules: [
Validator.isRequired('#user_email'),
Validator.isEmail('#user_email'),
Validator.isRequired('#user_name'),
Validator.isRequired('#user_address'),
Validator.isRequired('#user_phone'),
Validator.isRequired('#user_current_password'),
Validator.isConfirmed('#user_password_confirmation', function() {
return document.querySelector('#new_user #user_password').value;
}, 'Those passwords didn’t match.'),
]
})
\ No newline at end of file
- provide(:title, "Sign Up")
- provide(:title, 'Sign Up')
.container
.row.justify-content-center
......@@ -6,23 +6,23 @@
h2.text-center.my-5
| Sign up
= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
= render "users/shared/error_messages", resource: resource
= render 'users/shared/error_messages', resource: resource
.field
= f.label :email, class: 'form-label'
br
= f.email_field :email, autofocus: true, autocomplete: "email", class: 'form-control mb-2'
= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control mb-2'
.field
= f.label :name, class: 'form-label'
br
= f.text_field :name, autofocus: true, autocomplete: "name", class: 'form-control mb-2'
= f.text_field :name, autofocus: true, autocomplete: 'name', class: 'form-control mb-2'
.field
= f.label :address, class: 'form-label'
br
= f.text_field :address, autofocus: true, autocomplete: "address", class: 'form-control mb-2'
= f.text_field :address, autofocus: true, autocomplete: 'address', class: 'form-control mb-2'
.field
= f.label :phone, class: 'form-label'
br
= f.text_field :phone, autofocus: true, autocomplete: "phone", class: 'form-control mb-2'
= f.text_field :phone, autofocus: true, autocomplete: 'phone', class: 'form-control mb-2'
.field
= f.label :password, class: 'form-label'
- if @minimum_password_length
......@@ -31,11 +31,11 @@
= @minimum_password_length
| characters minimum)
br
= f.password_field :password, autocomplete: "new-password", class: 'form-control mb-2'
= f.password_field :password, autocomplete: 'new-password', class: 'form-control mb-2'
.field
= f.label :password_confirmation, class: 'form-label'
br
= f.password_field :password_confirmation, autocomplete: "new-password", class: 'form-control mb-2'
= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control mb-2'
.actions
= f.submit "Sign up", class: "btn btn-primary w-100 my-5"
= render "users/shared/links"
\ No newline at end of file
= f.submit 'Sign up', class: 'btn btn-primary w-100 my-5'
= render 'users/shared/links'
\ No newline at end of file
- provide(:title, 'Log in')
.container
.row.justify-content-center
.col-6
h2.text-center.my-5
| Log in
= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
.field
.field.row.form-group.mb-4
.col-2
= f.label :email, class: 'form-label'
br
= f.email_field :email, autofocus: true, autocomplete: "email", class: 'form-control mb-2'
.field
.col-10
= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control mb-2'
span.form-msg
.field.row.form-group.mb-4
.col-2
= f.label :password, class: 'form-label'
br
= f.password_field :password, autocomplete: "current-password", class: 'form-control mb-2'
.col-10
= f.password_field :password, autocomplete: 'current-password', class: 'form-control mb-2'
span.form-msg
- if devise_mapping.rememberable?
.field
= f.check_box :remember_me
= f.label :remember_me, class: 'form-label'
.actions
= f.submit "Log in", class: "btn btn-primary w-100 my-5"
= render "users/shared/links"
\ No newline at end of file
= f.label :remember_me, class: 'form-label mx-2'
- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations'
= link_to 'Forgot password?', forgot_password_path, class: 'text-decoration-none'
.actions.row.justify-content-end
.col-10.d-flex.justify-content-around
= f.submit 'Log in', class: 'btn btn-primary w-25', data: { disable_with: false }
= link_to 'Sign up', new_registration_path(resource_name), class: 'text-decoration-none w-25 btn btn-secondary'
javascript:
Validator({
form: '#new_user',
errorSelector: '.form-msg',
rules: [
Validator.isRequired('#user_email'),
Validator.isEmail('#user_email'),
Validator.isRequired('#user_password')
]
})
- if controller_name != 'sessions'
= link_to "Log in", new_session_path(resource_name), class: 'text-decoration-none'
= link_to 'Log in', new_session_path(resource_name), class: 'text-decoration-none'
br/
- if devise_mapping.registerable? && controller_name != 'registrations'
= link_to "Sign up", new_registration_path(resource_name), class: 'text-decoration-none'
= link_to 'Sign up', new_registration_path(resource_name), class: 'text-decoration-none btn btn-primary'
br/
- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations'
= link_to "Forgot your password?", new_password_path(resource_name), class: 'text-decoration-none'
= link_to 'Forgot your password?', new_password_path(resource_name), class: 'text-decoration-none'
br/
- if devise_mapping.confirmable? && controller_name != 'confirmations'
= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name), class: 'text-decoration-none'
= link_to 'Didn't receive confirmation instructions?', new_confirmation_path(resource_name), class: 'text-decoration-none'
br/
- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name), class: 'text-decoration-none'
= link_to 'Didn't receive unlock instructions?', new_unlock_path(resource_name), class: 'text-decoration-none'
br/
- if devise_mapping.omniauthable?
- resource_class.omniauth_providers.each do |provider|
= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), method: :post, class: 'text-decoration-none'
= link_to 'Sign in with #{OmniAuth::Utils.camelize(provider)}', omniauth_authorize_path(resource_name, provider), method: :post, class: 'text-decoration-none'
br/
......@@ -24,7 +24,7 @@ Devise.setup do |config|
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class
# with default "from" parameter.
config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
config.mailer_sender = 'user@venjob.com'
# Configure the class responsible to send e-mails.
# config.mailer = 'Devise::Mailer'
......
Rails.application.routes.draw do
devise_for :users
devise_scope :user do
get '/login', to: 'devise/sessions#new', as: :login
get '/my/info', to: 'devise/registrations#edit', as: :edit_profile
get '/forgot_password', to: 'devise/passwords#new', as: :forgot_password
get '/reset_password', to: 'devise/passwords#edit', as: :reset_password
end
root 'top#index'
resources :cities, only: %i[index]
......@@ -7,8 +13,7 @@ Rails.application.routes.draw do
get '/jobs/:model/:slug', to: 'jobs#index', as: :job_list
resources :jobs, only: %i[index show]
resources :users, only: %i[index show]
get '/my', to: 'users#show', as: :user_profile
get '/apply', to: 'applies#new', as: :apply_job
post '/confirm', to: 'applies#confirm', as: :confirm_job
......
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