Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: bryans-go <[email protected]>
  • Loading branch information
divanshu-go committed Sep 28, 2024
1 parent e90eb62 commit 3a98b23
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions lib/algora_web/live/show_live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -341,30 +341,33 @@ defmodule AlgoraWeb.ShowLive.Show do
end

defp apply_action(socket, :edit, %{"slug" => slug}) do
%{current_user: current_user} = socket.assigns
%{current_user: current_user} = socket.assigns

show = Shows.get_show_by_fields!(slug: slug)
show = Shows.get_show_by_fields!(slug: slug)

conn = Phoenix.LiveView.get_connect_info(socket).conn
conn_info = Phoenix.LiveView.get_connect_info(socket)
request_path = socket.assigns[:request_path] || ""
query_string = conn_info[:query_string] || ""
return_to = if query_string == "", do: request_path, else: request_path <> "?" <> query_string

cond do
current_user == nil ->
conn
|> maybe_store_return_to()
|> redirect(to: ~p"/auth/login")
cond do
current_user == nil ->
socket
|> Phoenix.LiveView.put_session(:user_return_to, return_to)
|> redirect(to: ~p"/auth/login")

current_user.id != show.user_id && !Accounts.admin?(current_user) ->
socket
|> put_flash(:error, "You don't have permission to edit this show")
|> redirect(to: ~p"/shows/#{show.slug}")
current_user.id != show.user_id && !Accounts.admin?(current_user) ->
socket
|> put_flash(:error, "You don't have permission to edit this show")
|> redirect(to: ~p"/shows/#{show.slug}")

true ->
socket
|> assign(:page_title, show.title)
|> assign(:page_description, show.description)
|> assign(:page_image, show.og_image_url)
end
true ->
socket
|> assign(:page_title, show.title)
|> assign(:page_description, show.description)
|> assign(:page_image, show.og_image_url)
end
end

defp assign_attendees(socket, show) do
attendees = Events.fetch_attendees(show)
Expand Down

0 comments on commit 3a98b23

Please sign in to comment.