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
6492bb29
Commit
6492bb29
authored
Aug 17, 2020
by
Huỳnh Thiên Phước
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix logic update form
parent
aaab73c8
Pipeline
#920
failed with stages
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
8 deletions
+11
-8
app/controllers/users_controller.rb
+10
-7
app/models/user.rb
+1
-1
No files found.
app/controllers/users_controller.rb
View file @
6492bb29
class
UsersController
<
ApplicationController
class
UsersController
<
ApplicationController
before_action
:sign
ed_in_user
,
only:
[
:update
,
:my_page
,
:my_info
]
before_action
:sign
_in_validation
,
only:
[
:update
,
:my_page
,
:my_info
]
def
my_page
def
my_page
end
end
...
@@ -7,7 +7,7 @@ class UsersController < ApplicationController
...
@@ -7,7 +7,7 @@ class UsersController < ApplicationController
end
end
def
update
def
update
user_params
[
:password
]
=
current_user
.
password_digest
if
user_params
[
:password
].
nil
?
user_params
[
:password
]
=
current_user
.
password_digest
if
user_params
[
:password
].
blank
?
if
BCrypt
::
Password
.
new
(
current_user
.
password_digest
)
!=
condition_update
[
:oldpassword
]
if
BCrypt
::
Password
.
new
(
current_user
.
password_digest
)
!=
condition_update
[
:oldpassword
]
flash
.
now
[
:danger
]
=
'Old Password is mismatch'
flash
.
now
[
:danger
]
=
'Old Password is mismatch'
else
else
...
@@ -24,11 +24,14 @@ class UsersController < ApplicationController
...
@@ -24,11 +24,14 @@ class UsersController < ApplicationController
private
private
def
signed_in_user
def
validate_oldpass
unless
signed_in?
flash
[
:warning
]
=
"Please Sign In..."
end
redirect_to
login_path
end
def
sign_in_validation
return
if
signed_in?
flash
[
:warning
]
=
"Please Sign In..."
redirect_to
login_path
end
end
def
user_params
def
user_params
...
...
app/models/user.rb
View file @
6492bb29
...
@@ -19,7 +19,7 @@ class User < ApplicationRecord
...
@@ -19,7 +19,7 @@ class User < ApplicationRecord
validates
:password
,
allow_nil:
true
,
length:
{
minimum:
6
,
too_short:
"is blank or too short"
}
validates
:password
,
allow_nil:
true
,
length:
{
minimum:
6
,
too_short:
"is blank or too short"
}
def
User
.
new_remember_token
def
self
.
new_remember_token
SecureRandom
.
urlsafe_base64
SecureRandom
.
urlsafe_base64
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