Fakultas Ilmu Komputer UI

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

Merge branch 'deploy-runtime' into 'master'

Add resctriction only admin could delete topic

See merge request !4
parents 21487729 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
......
Markdown is supported
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