Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
Venjob
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hoang Nam Nguyen
Venjob
Commits
fdf3dc0c
Commit
fdf3dc0c
authored
Oct 03, 2017
by
Hoang Nam Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'fixed forgot_page'
parent
5080eb67
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
41 additions
and
23 deletions
+41
-23
app/assets/stylesheets/custom.scss
+5
-0
app/controllers/applies_controller.rb
+16
-3
app/controllers/password_resets_controller.rb
+1
-1
app/controllers/users_controller.rb
+2
-2
app/models/apply.rb
+4
-0
app/models/user.rb
+6
-10
app/views/applies/confirm_apply.html.erb
+2
-1
app/views/applies/new.html.erb
+1
-3
app/views/job/detail.html.erb
+1
-1
app/views/password_resets/edit.html.erb
+1
-1
config/routes.rb
+2
-1
No files found.
app/assets/stylesheets/custom.scss
View file @
fdf3dc0c
...
@@ -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
app/controllers/applies_controller.rb
View file @
fdf3dc0c
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
co
n
firm_apply
@user_apply
=
Apply
.
find
(
params
[
:id
])
end
end
private
def
user_apply
params
.
require
(
:apply
).
permit
(
:email
,
:name
)
end
end
end
app/controllers/password_resets_controller.rb
View file @
fdf3dc0c
...
@@ -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
...
...
app/controllers/users_controller.rb
View file @
fdf3dc0c
...
@@ -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_attribute
s
(
:activated
=>
true
)
@user
.
update_attribute
(
:activated_at
,
Time
.
zone
.
now
)
@user
.
update_attribute
s
(
: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
...
...
app/models/apply.rb
View file @
fdf3dc0c
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
app/models/user.rb
View file @
fdf3dc0c
...
@@ -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
...
...
app/views/applies/confirm_apply.html.erb
View file @
fdf3dc0c
...
@@ -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>
...
...
app/views/applies/new.html.erb
View file @
fdf3dc0c
...
@@ -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>
app/views/job/detail.html.erb
View file @
fdf3dc0c
...
@@ -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>
...
...
app/views/password_resets/edit.html.erb
View file @
fdf3dc0c
...
@@ -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"
>
...
...
config/routes.rb
View file @
fdf3dc0c
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment