Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jonathan Nicholas
Diskuy-Backend
Commits
a4e7016a
Commit
a4e7016a
authored
Feb 19, 2021
by
Muhammad Rafif Elfazri
Browse files
Add resctriction only admin could delete topic
parent
720becab
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/diskuy_web/controllers/topic_controller.ex
View file @
a4e7016a
...
...
@@ -40,8 +40,9 @@ defmodule DiskuyWeb.TopicController do
def
delete
(
conn
,
%{
"id"
=>
id
})
do
topic
=
Forum
.
get_topic_by_name!
(
id
)
with
{
:ok
,
%
Topic
{}}
<-
Forum
.
delete_topic
(
topic
)
do
current_user
=
Guardian
.
Plug
.
current_resource
(
conn
)
with
{
:ok
,
:authorized
}
<-
Guardian
.
check_admin
(
current_user
),
{
:ok
,
%
Topic
{}}
<-
Forum
.
delete_topic
(
topic
)
do
send_resp
(
conn
,
:no_content
,
""
)
end
end
...
...
Write
Preview
Supports
Markdown
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