Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/algora/accounts/accounts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions lib/algora/payments/payments.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/algora_web/components/bounties.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule AlgoraWeb.Components.Bounties do
<div class="relative -mx-2 -mt-2 overflow-auto scrollbar-thin">
<ul class="divide-y divide-border">
<%= 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">
<li class="flex items-center py-2 px-3">
<div class="flex-shrink-0 mr-3">
<.avatar class="h-8 w-8">
Expand Down
11 changes: 9 additions & 2 deletions lib/algora_web/controllers/user_auth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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] ->
Expand Down
3 changes: 2 additions & 1 deletion lib/algora_web/live/org/bounties_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ defmodule AlgoraWeb.Org.BountiesLive do
</div>
</div>
<.link
rel="noopener"
class="group/issue inline-flex flex-col"
target="_blank"
rel="noopener noreferrer"
href={Bounty.url(bounty)}
>
<div :if={Bounty.path(bounty)} class="flex items-center gap-4">
Expand Down
4 changes: 3 additions & 1 deletion lib/algora_web/live/org/bounties_new_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ defmodule AlgoraWeb.Org.BountiesNewLive do
</div>

<.link
target="_blank"
rel="noopener noreferrer"
href={Bounty.url(bounty)}
class="max-w-[400px] truncate text-sm text-foreground hover:underline"
>
Expand All @@ -165,7 +167,7 @@ defmodule AlgoraWeb.Org.BountiesNewLive do

<div 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)}
</.link>
</div>
Expand Down
3 changes: 2 additions & 1 deletion lib/algora_web/live/org/dashboard_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,9 @@ defmodule AlgoraWeb.Org.DashboardLive do
</div>
</div>
<.link
rel="noopener"
class="group/issue inline-flex flex-col"
target="_blank"
rel="noopener noreferrer"
href={Bounty.url(bounty)}
>
<div :if={Bounty.path(bounty)} class="flex items-center gap-4">
Expand Down
4 changes: 3 additions & 1 deletion lib/algora_web/live/org/home_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ defmodule AlgoraWeb.Org.HomeLive do
</div>

<.link
target="_blank"
rel="noopener noreferrer"
href={Bounty.url(bounty)}
class="max-w-[400px] truncate text-sm text-foreground hover:underline"
>
Expand All @@ -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)}
</.link>
</div>
Expand Down
4 changes: 3 additions & 1 deletion lib/algora_web/live/org/transactions_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/algora_web/live/user/transactions_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)}

Expand Down