Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VietTH-VenShop
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
4
Merge Requests
4
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
Tran Hoang Viet
VietTH-VenShop
Commits
b2a7ec46
Commit
b2a7ec46
authored
Jul 29, 2015
by
Tran Hoang Viet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VieTH: Fix authorise admin
parent
f8bcc373
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
3 deletions
+11
-3
app/controllers/admin/application_controller.rb
+9
-0
app/controllers/admin/orders_controller.rb
+1
-2
app/controllers/orders_controller.rb
+1
-1
No files found.
app/controllers/admin/application_controller.rb
0 → 100644
View file @
b2a7ec46
class
Admin
::
ApplicationController
<
ApplicationController
before_action
:authenticate_admin!
private
def
authenticate_admin!
redirect_to
root_path
,
alert:
'You are not permission.'
unless
current_user
.
try
(
:admin?
)
end
end
app/controllers/admin/orders_controller.rb
View file @
b2a7ec46
class
Admin
::
OrdersController
<
ApplicationController
class
Admin
::
OrdersController
<
A
dmin
::
A
pplicationController
before_action
:set_order
,
only:
[
:show
,
:update
]
before_action
->
{
authorize
(
@order
)
},
only:
[
:show
,
:update
]
def
index
@orders
=
Order
.
all
.
includes
(
:user
).
order
(
created_at: :desc
).
page
(
params
[
:page
])
...
...
app/controllers/orders_controller.rb
View file @
b2a7ec46
class
OrdersController
<
ApplicationController
before_action
:authenticate_user!
before_action
:set_order
,
only:
[
:show
,
:update
]
before_action
->
{
authorize
(
@order
)
},
only:
[
:show
,
:update
]
before_action
->
{
authorize
(
@order
)
},
only:
[
:show
]
def
index
@orders
=
current_user
.
orders
.
includes
(
:user
).
order
(
created_at: :desc
).
page
(
params
[
:page
])
...
...
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