Skip to content

Commit

Permalink
Auth permission updates
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Jun 26, 2023
1 parent 56ff5a8 commit 3dc2795
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions lib/ret_web/channels/hub_channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -297,17 +297,23 @@ defmodule RetWeb.HubChannel do
account = Guardian.Phoenix.Socket.current_resource(socket)
hub = socket |> hub_for_socket

if (type != "photo" and type != "video") or account |> can?(spawn_camera(hub)) do
broadcast!(
socket,
event,
payload
|> Map.delete("session_id")
|> Map.put(:session_id, socket.assigns.session_id)
|> payload_with_from(socket)
)
if (type == "photo" and type == "video" and
account
|> can?(spawn_camera(hub))
|> Kernel.not()) or
(type == "permission" and hub |> Ret.Hub.is_owner?(account.account_id) |> Kernel.not()) do
{:noreply, socket}
end

broadcast!(
socket,
event,
payload
|> Map.delete("session_id")
|> Map.put(:session_id, socket.assigns.session_id)
|> payload_with_from(socket)
)

{:noreply, socket}
end

Expand Down

0 comments on commit 3dc2795

Please sign in to comment.