diff --git a/lib/algora/accounts/accounts.ex b/lib/algora/accounts/accounts.ex index 6ceefe945..ac512243a 100644 --- a/lib/algora/accounts/accounts.ex +++ b/lib/algora/accounts/accounts.ex @@ -617,7 +617,13 @@ defmodule Algora.Accounts do def get_last_context_user(nil), do: nil def get_last_context_user(%User{} = user) do - case last_context(user) do + get_context_user(user, last_context(user)) + end + + def get_context_user(nil, _context), do: nil + + def get_context_user(%User{} = user, context) do + case context do "personal" -> user @@ -630,8 +636,8 @@ defmodule Algora.Accounts do "repo/" <> _repo_full_name -> user - last_context -> - get_user_by_handle(last_context) + handle -> + get_user_by_handle(handle) end end diff --git a/lib/algora/payments/payments.ex b/lib/algora/payments/payments.ex index 0d4f8abe1..cc447f5b3 100644 --- a/lib/algora/payments/payments.ex +++ b/lib/algora/payments/payments.ex @@ -303,14 +303,14 @@ defmodule Algora.Payments do end end - @spec create_account_link(account :: Account.t(), base_url :: String.t()) :: + @spec create_account_link(account :: Account.t(), base_url :: String.t(), type :: String.t()) :: {:ok, PSP.account_link()} | {:error, PSP.error()} - def create_account_link(account, base_url) do + def create_account_link(account, base_url, type \\ "account_onboarding") do PSP.AccountLink.create(%{ account: account.provider_id, refresh_url: "#{base_url}/callbacks/stripe/refresh", return_url: "#{base_url}/callbacks/stripe/return", - type: "account_onboarding" + type: type }) end diff --git a/lib/algora_web/components/bounties.ex b/lib/algora_web/components/bounties.ex index 2d6e6adb2..8228a93d8 100644 --- a/lib/algora_web/components/bounties.ex +++ b/lib/algora_web/components/bounties.ex @@ -12,7 +12,7 @@ defmodule AlgoraWeb.Components.Bounties do
<.link - rel="noopener" class="group/issue inline-flex flex-col" + target="_blank" + rel="noopener noreferrer" href={Bounty.url(bounty)} >
diff --git a/lib/algora_web/live/org/bounties_new_live.ex b/lib/algora_web/live/org/bounties_new_live.ex index ac591dd35..c3ad2e6d5 100644 --- a/lib/algora_web/live/org/bounties_new_live.ex +++ b/lib/algora_web/live/org/bounties_new_live.ex @@ -157,6 +157,8 @@ defmodule AlgoraWeb.Org.BountiesNewLive do
<.link + target="_blank" + rel="noopener noreferrer" href={Bounty.url(bounty)} class="max-w-[400px] truncate text-sm text-foreground hover:underline" > @@ -165,7 +167,7 @@ defmodule AlgoraWeb.Org.BountiesNewLive do
<.icon name="tabler-chevron-right" class="h-4 w-4" /> - <.link href={Bounty.url(bounty)} class="hover:underline"> + <.link target="_blank" rel="noopener noreferrer" href={Bounty.url(bounty)} class="hover:underline"> {Bounty.path(bounty)}
diff --git a/lib/algora_web/live/org/dashboard_live.ex b/lib/algora_web/live/org/dashboard_live.ex index e295deae5..6a8ec8fc3 100644 --- a/lib/algora_web/live/org/dashboard_live.ex +++ b/lib/algora_web/live/org/dashboard_live.ex @@ -235,8 +235,9 @@ defmodule AlgoraWeb.Org.DashboardLive do <.link - rel="noopener" class="group/issue inline-flex flex-col" + target="_blank" + rel="noopener noreferrer" href={Bounty.url(bounty)} >
diff --git a/lib/algora_web/live/org/home_live.ex b/lib/algora_web/live/org/home_live.ex index d55e34d42..67ca7f254 100644 --- a/lib/algora_web/live/org/home_live.ex +++ b/lib/algora_web/live/org/home_live.ex @@ -162,6 +162,8 @@ defmodule AlgoraWeb.Org.HomeLive do
<.link + target="_blank" + rel="noopener noreferrer" href={Bounty.url(bounty)} class="max-w-[400px] truncate text-sm text-foreground hover:underline" > @@ -173,7 +175,7 @@ defmodule AlgoraWeb.Org.HomeLive do class="flex shrink-0 items-center gap-1 whitespace-nowrap text-sm text-muted-foreground" > <.icon name="tabler-chevron-right" class="h-4 w-4" /> - <.link href={Bounty.url(bounty)} class="hover:underline"> + <.link target="_blank" rel="noopener noreferrer" href={Bounty.url(bounty)} class="hover:underline"> {Bounty.path(bounty)} diff --git a/lib/algora_web/live/org/transactions_live.ex b/lib/algora_web/live/org/transactions_live.ex index 13e708f0c..1384340c5 100644 --- a/lib/algora_web/live/org/transactions_live.ex +++ b/lib/algora_web/live/org/transactions_live.ex @@ -77,7 +77,9 @@ defmodule AlgoraWeb.Org.TransactionsLive do end def handle_event("setup_payout_account", _params, socket) do - case Payments.create_account_link(socket.assigns.account, AlgoraWeb.Endpoint.url()) do + type = if socket.assigns.account.details_submitted, do: "account_update", else: "account_onboarding" + + case Payments.create_account_link(socket.assigns.account, AlgoraWeb.Endpoint.url(), type) do {:ok, %{url: url}} -> {:noreply, redirect(socket, external: url)} {:error, _reason} -> {:noreply, put_flash(socket, :error, "Something went wrong")} end diff --git a/lib/algora_web/live/user/transactions_live.ex b/lib/algora_web/live/user/transactions_live.ex index a40271a08..3159d069f 100644 --- a/lib/algora_web/live/user/transactions_live.ex +++ b/lib/algora_web/live/user/transactions_live.ex @@ -75,7 +75,9 @@ defmodule AlgoraWeb.User.TransactionsLive do end def handle_event("setup_payout_account", _params, socket) do - case Payments.create_account_link(socket.assigns.account, AlgoraWeb.Endpoint.url()) do + type = if socket.assigns.account.details_submitted, do: "account_update", else: "account_onboarding" + + case Payments.create_account_link(socket.assigns.account, AlgoraWeb.Endpoint.url(), type) do {:ok, %{url: url}} -> {:noreply, redirect(socket, external: url)}