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
0
Merge Requests
0
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
Huỳnh Thiên Phước
venjob
Commits
5aa6a5be
Commit
5aa6a5be
authored
Aug 24, 2020
by
Huỳnh Thiên Phước
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change level of development.yml, add callback in reset_password
parent
4fc05e8f
Pipeline
#1083
failed with stages
in 0 seconds
Changes
7
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
59 additions
and
29 deletions
+59
-29
app/controllers/confirmations_controller.rb
+2
-2
app/controllers/job_applieds_controller.rb
+30
-0
app/controllers/reset_passwords_controller.rb
+13
-9
app/controllers/sessions_controller.rb
+1
-1
app/models/confirmation.rb
+0
-4
config/routes.rb
+4
-4
config/settings/development.yml
+9
-9
No files found.
app/controllers/confirmations_controller.rb
View file @
5aa6a5be
...
@@ -6,12 +6,12 @@ class ConfirmationsController < ApplicationController
...
@@ -6,12 +6,12 @@ class ConfirmationsController < ApplicationController
def
mail_register
def
mail_register
email
=
params
[
:confirmation
][
:email
].
downcase
email
=
params
[
:confirmation
][
:email
].
downcase
if
User
.
find_by
(
email:
email
)
if
User
.
find_by
(
email:
email
)
flash
[
:danger
]
=
Settings
.
sign_up
.
email_
existed
flash
[
:danger
]
=
Settings
.
user
.
sign_up
.
existed
redirect_to
register_step1_path
redirect_to
register_step1_path
end
end
@user
=
Confirmation
.
find_or_initialize_by
(
email:
email
)
@user
=
Confirmation
.
find_or_initialize_by
(
email:
email
)
unless
@user
.
save
unless
@user
.
save
flash
[
:danger
]
=
Settings
.
sign_up
.
email_
format_failed
flash
[
:danger
]
=
Settings
.
user
.
sign_up
.
format_failed
return
redirect_to
register_step1_path
return
redirect_to
register_step1_path
end
end
...
...
app/controllers/job_applieds_controller.rb
0 → 100644
View file @
5aa6a5be
class
JobAppliedsController
<
ApplicationController
before_action
:sign_in_validation
,
only:
[
:new
,
:confirmation
,
:create
]
def
new
end
def
confirmation
@user
=
JobApplied
.
new
(
apply_params
)
return
root_path
unless
apply_params
end
def
create
binding
.
pry
@user
=
JobApplied
.
new
(
apply_params
)
return
root_path
unless
@user
return
job_detail_path
(
apply_params
[
:job_id
])
unless
@user
.
save
end
private
def
sign_in_validation
return
if
signed_in?
flash
[
:warning
]
=
Settings
.
user
.
warning_signin
redirect_to
login_path
end
def
apply_params
params
.
require
(
:job_applied
).
permit
(
:name
,
:email
,
:job_id
,
:cv_user
)
end
end
app/controllers/reset_passwords_controller.rb
View file @
5aa6a5be
class
ResetPasswordsController
<
ApplicationController
class
ResetPasswordsController
<
ApplicationController
before_action
:find_token_param
,
only:
[
:edit
]
def
reset_password
def
reset_password
end
end
...
@@ -6,20 +7,19 @@ class ResetPasswordsController < ApplicationController
...
@@ -6,20 +7,19 @@ class ResetPasswordsController < ApplicationController
def
sending_email
def
sending_email
@user
=
User
.
find_by
(
email:
params
[
:reset_password
][
:email
].
downcase
)
@user
=
User
.
find_by
(
email:
params
[
:reset_password
][
:email
].
downcase
)
unless
@user
unless
@user
flash
[
:danger
]
=
Settings
.
reset_password
.
sending_email_failed
flash
[
:danger
]
=
Settings
.
user
.
reset_password
.
failed
redirect_to
reset_password_step1_path
else
else
forgot_token
=
Digest
::
SHA1
.
hexdigest
(
SecureRandom
.
urlsafe_base64
)
forgot_token
=
Digest
::
SHA1
.
hexdigest
(
SecureRandom
.
urlsafe_base64
)
@user
.
update_attribute
(
:remember_token
,
forgot_token
)
@user
.
update_attribute
(
:remember_token
,
forgot_token
)
ResetPasswordMailer
.
reset_password
(
@user
).
deliver_later
ResetPasswordMailer
.
reset_password
(
@user
).
deliver_later
flash
[
:success
]
=
Settings
.
reset_password
.
sending_email_success
flash
[
:success
]
=
Settings
.
user
.
reset_password
.
success
redirect_to
reset_password_step1_path
end
end
redirect_to
reset_password_step1_path
end
end
def
edit
def
edit
@user
=
User
.
find_by
(
remember_token:
params
[
:token
])
@user
=
User
.
find_by
(
remember_token:
params
[
:token
])
return
redirect_to
reset_password_step1_path
unless
@user
&&
params
[
:token
]
return
redirect_to
reset_password_step1_path
unless
@user
if
@user
.
token_expired?
if
@user
.
token_expired?
flash
[
:danger
]
=
Settings
.
user
.
expiration
flash
[
:danger
]
=
Settings
.
user
.
expiration
redirect_to
register_step1_path
redirect_to
register_step1_path
...
@@ -28,18 +28,22 @@ class ResetPasswordsController < ApplicationController
...
@@ -28,18 +28,22 @@ class ResetPasswordsController < ApplicationController
def
update
def
update
@user
=
User
.
find_by
(
email:
params
[
:user
][
:email
])
@user
=
User
.
find_by
(
email:
params
[
:user
][
:email
])
unless
@user
.
update_attributes
(
forgot_pass_params
)
if
@user
.
update_attributes
(
forgot_pass_params
)
flash
[
:danger
]
=
Settings
.
reset_password
.
update_reset_pass
redirect_to
reset_password_final_path
(
token:
@user
.
remember_token
)
else
sign_in
@user
sign_in
@user
flash
[
:success
]
=
Settings
.
general_notify
.
update_success
flash
[
:success
]
=
Settings
.
general_notify
.
update_success
redirect_to
my_page_path
redirect_to
my_page_path
else
flash
[
:danger
]
=
Settings
.
user
.
reset_password
.
update_reset_pass
redirect_to
reset_password_final_path
(
token:
@user
.
remember_token
)
end
end
end
end
private
private
def
find_token_param
return
redirect_to
reset_password_step1_path
unless
params
[
:token
]
end
def
forgot_pass_params
def
forgot_pass_params
params
.
require
(
:user
).
permit
(
:password
,
:password_confirmation
)
params
.
require
(
:user
).
permit
(
:password
,
:password_confirmation
)
end
end
...
...
app/controllers/sessions_controller.rb
View file @
5aa6a5be
...
@@ -10,7 +10,7 @@ class SessionsController < ApplicationController
...
@@ -10,7 +10,7 @@ class SessionsController < ApplicationController
sign_in
user
sign_in
user
redirect_to
my_page_path
redirect_to
my_page_path
else
else
flash
.
now
[
:danger
]
=
Settings
.
sign_in
.
sign_in_
failed
flash
.
now
[
:danger
]
=
Settings
.
user
.
sign_in
.
failed
render
'new'
render
'new'
end
end
end
end
...
...
app/models/confirmation.rb
View file @
5aa6a5be
...
@@ -13,10 +13,6 @@ class Confirmation < ApplicationRecord
...
@@ -13,10 +13,6 @@ class Confirmation < ApplicationRecord
Digest
::
SHA1
.
hexdigest
(
token
.
to_s
)
Digest
::
SHA1
.
hexdigest
(
token
.
to_s
)
end
end
def
token_expired?
updated_at
<=
24
.
hours
.
ago
end
private
private
def
create_confirm_token
def
create_confirm_token
...
...
config/routes.rb
View file @
5aa6a5be
...
@@ -28,10 +28,10 @@ Rails.application.routes.draw do
...
@@ -28,10 +28,10 @@ Rails.application.routes.draw do
get
'jobs/company/:converted_name'
,
to:
'jobs#company_jobs'
,
as: :company_jobs
get
'jobs/company/:converted_name'
,
to:
'jobs#company_jobs'
,
as: :company_jobs
resources
:reset_passwords
,
only:
[
:edit
,
:update
]
resources
:reset_passwords
,
only:
[
:edit
,
:update
]
resources
:confirmations
resources
:confirmations
,
only:
[
:new
]
resources
:top_pages
resources
:top_pages
,
only:
[
:index
]
resources
:industries
resources
:industries
,
only:
[
:index
]
resources
:cities
resources
:cities
,
only:
[
:index
]
root
to:
"top_pages#index"
root
to:
"top_pages#index"
end
end
...
...
config/settings/development.yml
View file @
5aa6a5be
...
@@ -6,15 +6,15 @@ user:
...
@@ -6,15 +6,15 @@ user:
password_mismatch
:
'
Password
is
mismatch'
password_mismatch
:
'
Password
is
mismatch'
warning_signin
:
'
Please
Sign
In...'
warning_signin
:
'
Please
Sign
In...'
reset_password
:
reset_password
:
sending_email_
failed
:
'
Your
Email
invalid
or
not
register'
failed
:
'
Your
Email
invalid
or
not
register'
sending_email_
success
:
'
Please
check
your
email
to
change
your
password'
success
:
'
Please
check
your
email
to
change
your
password'
update_reset_pass
:
'
Password
or
Password
Confirmation
is
mismatch'
update_reset_pass
:
'
Password
or
Password
Confirmation
is
mismatch'
sign_in
:
sign_in
:
sign_in_
failed
:
'
Invalid
email
or
password'
failed
:
'
Invalid
email
or
password'
sign_up
:
sign_up
:
email_
existed
:
'
Email
existed.
Please
change
!!!'
existed
:
'
Email
existed.
Please
change
!!!'
email_
format_failed
:
'
Email
formated
invalid'
format_failed
:
'
Email
formated
invalid'
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