Fakultas Ilmu Komputer UI

Commit a4e7016a authored by Muhammad Rafif Elfazri's avatar Muhammad Rafif Elfazri
Browse files

Add resctriction only admin could delete topic

parent 720becab
......@@ -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, "")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment