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
e5684e9f
Commit
e5684e9f
authored
Aug 21, 2020
by
Huỳnh Thiên Phước
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move text flash to yaml file
parent
5f7e6e42
Pipeline
#976
failed with stages
in 0 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
39 additions
and
36 deletions
+39
-36
app/controllers/confirmations_controller.rb
+2
-2
app/controllers/reset_passwords_controller.rb
+6
-6
app/controllers/sessions_controller.rb
+1
-1
app/controllers/users_controller.rb
+5
-5
app/models/reset_password.rb
+0
-22
config/application.rb
+5
-0
config/text_flash.yml
+20
-0
public/uploads/user/cv_user/64/Document-converted.pdf
+0
-0
No files found.
app/controllers/confirmations_controller.rb
View file @
e5684e9f
...
@@ -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
]
=
'Email existed. Please change !!!'
flash
[
:danger
]
=
ENV
[
'email_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
]
=
"Email formated invalid"
flash
[
:danger
]
=
ENV
[
'email_format_failed'
]
return
redirect_to
register_step1_path
return
redirect_to
register_step1_path
end
end
...
...
app/controllers/reset_passwords_controller.rb
View file @
e5684e9f
...
@@ -6,22 +6,22 @@ class ResetPasswordsController < ApplicationController
...
@@ -6,22 +6,22 @@ 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
]
=
"Your Email invalid or not register"
flash
[
:danger
]
=
ENV
[
'sending_email_failed'
]
redirect_to
reset_password_step1_path
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
]
=
"Please check your email to change your password"
flash
[
:success
]
=
ENV
[
'sending_email_success'
]
redirect_to
reset_password_step1_path
redirect_to
reset_password_step1_path
end
end
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
return
redirect_to
reset_password_step1_path
unless
@user
&&
params
[
:token
]
if
@user
.
token_expired?
if
@user
.
token_expired?
flash
[
:danger
]
=
"Link Confirmation is expiration too 24 hours to confirm. Please update your Email again!"
flash
[
:danger
]
=
ENV
[
'expiration'
]
redirect_to
register_step1_path
redirect_to
register_step1_path
end
end
end
end
...
@@ -29,11 +29,11 @@ class ResetPasswordsController < ApplicationController
...
@@ -29,11 +29,11 @@ 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
)
unless
@user
.
update_attributes
(
forgot_pass_params
)
flash
[
:danger
]
=
"Password or Password Confirmation is mismatch"
flash
[
:danger
]
=
ENV
[
'update_reset_pass'
]
redirect_to
reset_password_final_path
(
token:
@user
.
remember_token
)
redirect_to
reset_password_final_path
(
token:
@user
.
remember_token
)
else
else
sign_in
@user
sign_in
@user
flash
[
:success
]
=
'Updated Successfully'
flash
[
:success
]
=
ENV
[
'update_success'
]
redirect_to
my_page_path
redirect_to
my_page_path
end
end
end
end
...
...
app/controllers/sessions_controller.rb
View file @
e5684e9f
...
@@ -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
]
=
'Invalid email or password'
flash
.
now
[
:danger
]
=
ENV
[
'sign_in_failed'
]
render
'new'
render
'new'
end
end
end
end
...
...
app/controllers/users_controller.rb
View file @
e5684e9f
...
@@ -11,10 +11,10 @@ class UsersController < ApplicationController
...
@@ -11,10 +11,10 @@ class UsersController < ApplicationController
if
current_user
.
authenticate
(
params
[
:user
][
:password
])
if
current_user
.
authenticate
(
params
[
:user
][
:password
])
return
respond_to
{
|
format
|
format
.
js
}
unless
current_user
.
update_attributes
(
user_params
)
return
respond_to
{
|
format
|
format
.
js
}
unless
current_user
.
update_attributes
(
user_params
)
flash
[
:success
]
=
'Updated Successfully'
flash
[
:success
]
=
ENV
[
'update_success'
]
redirect_to
my_page_path
redirect_to
my_page_path
else
else
flash
.
now
[
:danger
]
=
'Password is mismatch'
flash
.
now
[
:danger
]
=
ENV
[
'password_mismatch'
]
end
end
end
end
...
@@ -22,7 +22,7 @@ class UsersController < ApplicationController
...
@@ -22,7 +22,7 @@ class UsersController < ApplicationController
@email
=
Confirmation
.
find_by
(
confirm_token:
params
[
:code
])
@email
=
Confirmation
.
find_by
(
confirm_token:
params
[
:code
])
return
redirect_to
register_step1_path
unless
@email
return
redirect_to
register_step1_path
unless
@email
if
@email
.
token_expired?
if
@email
.
token_expired?
flash
[
:danger
]
=
"Link Confirmation is expiration too 24 hours to confirm. Please update your Email again!"
flash
[
:danger
]
=
ENV
[
'expiration'
]
redirect_to
register_step1_path
redirect_to
register_step1_path
else
else
@user
=
User
.
new
@user
=
User
.
new
...
@@ -39,8 +39,8 @@ class UsersController < ApplicationController
...
@@ -39,8 +39,8 @@ class UsersController < ApplicationController
private
private
def
sign_in_validation
def
sign_in_validation
return
if
signed_in?
||
params
[
:remember_token
].
blank?
return
if
signed_in?
flash
[
:warning
]
=
"Please Sign In..."
flash
[
:warning
]
=
ENV
[
'warning_signin'
]
redirect_to
login_path
redirect_to
login_path
end
end
...
...
app/models/reset_password.rb
deleted
100644 → 0
View file @
5f7e6e42
class
ResetPassword
<
ApplicationRecord
before_save
:create_remember_token
has_secure_password
PASSWORD_FORMAT
=
/\A(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])/x
validates
:password
,
format:
{
with:
PASSWORD_FORMAT
,
message:
"is too short or not strength"
}
def
self
.
new_remember_token
SecureRandom
.
urlsafe_base64
end
def
self
.
digest
(
token
)
Digest
::
SHA1
.
hexdigest
(
token
.
to_s
)
end
private
def
create_remember_token
self
.
remember_token
=
User
.
digest
(
User
.
new_remember_token
)
end
end
config/application.rb
View file @
e5684e9f
...
@@ -15,6 +15,11 @@ module Venjob
...
@@ -15,6 +15,11 @@ module Venjob
YAML
.
load
(
File
.
open
(
env_file
)).
each
do
|
key
,
value
|
YAML
.
load
(
File
.
open
(
env_file
)).
each
do
|
key
,
value
|
ENV
[
key
.
to_s
]
=
value
ENV
[
key
.
to_s
]
=
value
end
if
File
.
exists?
(
env_file
)
end
if
File
.
exists?
(
env_file
)
text_file
=
File
.
join
(
Rails
.
root
,
'config'
,
'text_flash.yml'
)
YAML
.
load
(
File
.
open
(
text_file
)).
each
do
|
key
,
value
|
ENV
[
key
.
to_s
]
=
value
end
if
File
.
exists?
(
text_file
)
end
end
# config.filter_parameter_logging << :oldpassword, :password
# config.filter_parameter_logging << :oldpassword, :password
# Settings in config/environments/* take precedence over those specified here.
# Settings in config/environments/* take precedence over those specified here.
...
...
config/text_flash.yml
0 → 100644
View file @
e5684e9f
#GENERAL
update_success
:
'
Updated
Successfully'
#TEXT OF USER
expiration
:
'
Link
Confirmation
is
expiration
too
24
hours
to
confirm.
Please
update
your
Email
again!'
password_mismatch
:
'
Password
is
mismatch'
warning_signin
:
'
Please
Sign
In...'
#TEXT OF RESET PASSWORD
sending_email_failed
:
'
Your
Email
invalid
or
not
register'
sending_email_success
:
'
Please
check
your
email
to
change
your
password'
update_reset_pass
:
'
Password
or
Password
Confirmation
is
mismatch'
#TEXT OF SIGN IN
sign_in_failed
:
'
Invalid
email
or
password'
#TEXT OF SIGN UP
email_existed
:
'
Email
existed.
Please
change
!!!'
email_format_failed
:
'
Email
formated
invalid'
public/uploads/user/cv_user/64/Document-converted.pdf
0 → 100644
View file @
e5684e9f
File added
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