From 2a998cdaf234353deaacfb525eee638031e50cf4 Mon Sep 17 00:00:00 2001 From: Ishant5436 Date: Fri, 29 May 2026 20:22:16 +0530 Subject: [PATCH 1/3] fix: use account_update type for Stripe Connect when details are submitted --- lib/algora/payments/payments.ex | 6 +++--- lib/algora_web/live/org/transactions_live.ex | 4 +++- lib/algora_web/live/user/transactions_live.ex | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) 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/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)} From 185a873cf1d65c2489e876c351f15b6685ac3fff Mon Sep 17 00:00:00 2001 From: Ishant5436 Date: Fri, 29 May 2026 20:40:57 +0530 Subject: [PATCH 2/3] Fix login 404/500 errors by validating last_context --- lib/algora/accounts/accounts.ex | 12 +++++++++--- lib/algora_web/controllers/user_auth.ex | 11 +++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) 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_web/controllers/user_auth.ex b/lib/algora_web/controllers/user_auth.ex index e3f00b465..b05c8c241 100644 --- a/lib/algora_web/controllers/user_auth.ex +++ b/lib/algora_web/controllers/user_auth.ex @@ -241,12 +241,19 @@ defmodule AlgoraWeb.UserAuth do def signed_in_path_from_context(org_handle), do: ~p"/#{org_handle}/dashboard" def signed_in_path(%User{} = user) do - signed_in_path_from_context(Accounts.last_context(user)) + last_context = Accounts.last_context(user) + + if Accounts.get_context_user(user, last_context) do + signed_in_path_from_context(last_context) + else + signed_in_path_from_context(Accounts.default_context()) + end end def signed_in_path(conn) do cond do - last_context = get_session(conn, :last_context) -> + (last_context = get_session(conn, :last_context)) && conn.assigns[:current_user] && + Accounts.get_context_user(conn.assigns[:current_user], last_context) -> signed_in_path_from_context(last_context) user = conn.assigns[:current_user] -> From 8c414f10b1773c4a9500eb60d2171e569f287e82 Mon Sep 17 00:00:00 2001 From: Ishant5436 Date: Fri, 29 May 2026 20:48:14 +0530 Subject: [PATCH 3/3] Force external bounty links to open in _blank target --- lib/algora_web/components/bounties.ex | 2 +- lib/algora_web/live/org/bounties_live.ex | 3 ++- lib/algora_web/live/org/bounties_new_live.ex | 4 +++- lib/algora_web/live/org/dashboard_live.ex | 3 ++- lib/algora_web/live/org/home_live.ex | 4 +++- 5 files changed, 11 insertions(+), 5 deletions(-) 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
    <%= for bounty <- @bounties do %> - <.link href={Bounty.url(bounty)} class="block whitespace-nowrap hover:bg-muted/50"> + <.link target="_blank" rel="noopener" href={Bounty.url(bounty)} class="block whitespace-nowrap hover:bg-muted/50">
  • <.avatar class="h-8 w-8"> diff --git a/lib/algora_web/live/org/bounties_live.ex b/lib/algora_web/live/org/bounties_live.ex index 9dccffbd2..edfecd3d2 100644 --- a/lib/algora_web/live/org/bounties_live.ex +++ b/lib/algora_web/live/org/bounties_live.ex @@ -131,8 +131,9 @@ defmodule AlgoraWeb.Org.BountiesLive 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)}