Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
8d91943d
Commit
8d91943d
authored
8 years ago
by
Lucas Gabriel Lima
Browse files
Options
Downloads
Patches
Plain Diff
add checking of users permitions in taggable_controller
parent
c73afe12
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/controllers/concerns/taggable_controller.rb
+18
-3
18 additions, 3 deletions
app/controllers/concerns/taggable_controller.rb
with
18 additions
and
3 deletions
app/controllers/concerns/taggable_controller.rb
+
18
−
3
View file @
8d91943d
...
@@ -3,19 +3,20 @@ module TaggableController
...
@@ -3,19 +3,20 @@ module TaggableController
included
do
included
do
before_action
:authenticate_user!
,
only:
[
:tagging
,
:untagging
]
before_action
:authenticate_user!
,
only:
[
:tagging
,
:untagging
]
before_action
:set_owner
,
only:
[
:tagging
,
:untagging
]
end
end
# POST /v1/learning_objects/1/tagging
# POST /v1/learning_objects/1/tagging
# POST /v1/learning_objects/1/tagging.json
# POST /v1/learning_objects/1/tagging.json
def
tagging
def
tagging
current_us
er
.
tag
(
taggable
,
with:
[
tag_params
[
:name
]])
@own
er
.
tag
(
taggable
,
with:
[
tag_params
[
:name
]])
render
json:
taggable
,
status: :created
render
json:
taggable
,
status: :created
end
end
# DELETE /v1/learning_objects/1/untagging
# DELETE /v1/learning_objects/1/untagging
# DELETE /v1/learning_objects/1/untagging.json
# DELETE /v1/learning_objects/1/untagging.json
def
untagging
def
untagging
current_us
er
.
untag
(
taggable
,
tag_params
[
:name
])
@own
er
.
untag
(
taggable
,
tag_params
[
:name
])
render
json:
taggable
,
status: :ok
render
json:
taggable
,
status: :ok
end
end
...
@@ -26,7 +27,21 @@ module TaggableController
...
@@ -26,7 +27,21 @@ module TaggableController
end
end
def
tag_params
def
tag_params
params
.
require
(
:tag
).
permit
(
:name
)
params
.
require
(
:tag
).
permit
(
:name
,
:owner_id
,
:owner_type
)
end
def
set_owner
if
current_user
.
is_admin?
@owner
=
tag_params
[
:owner_type
].
constantize
.
find
(
tag_params
[
:owner_id
])
else
if
tag_params
[
:owner_type
]
==
'Institution'
if
Institution
.
find
(
tag_params
[
:owner_id
]).
users
.
include?
current_user
@owner
=
Institution
.
find
(
tag_params
[
:owner_id
])
end
else
@owner
=
current_user
end
end
end
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment