Skip to content
Merged
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
5 changes: 5 additions & 0 deletions lib/algora/accounts/schemas/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,9 @@ defmodule Algora.Accounts.User do
def url(%{handle: handle, type: :individual}), do: "/@/#{handle}"
def url(%{handle: handle, type: :organization}), do: "/org/#{handle}"
def url(%{provider_login: handle}), do: "https://github.com/#{handle}"

def last_context(%{last_context: nil}), do: default_context()
def last_context(%{last_context: last_context}), do: last_context

def default_context, do: "personal"
end
14 changes: 9 additions & 5 deletions lib/algora_web/controllers/user_auth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule AlgoraWeb.UserAuth do
import Plug.Conn

alias Algora.Accounts
alias Algora.Accounts.User
alias Phoenix.LiveView

def on_mount(:current_user, _params, session, socket) do
Expand Down Expand Up @@ -185,12 +186,15 @@ defmodule AlgoraWeb.UserAuth do

defp maybe_store_return_to(conn), do: conn

def signed_in_path_from_context("personal"), do: ~p"/home"
def signed_in_path_from_context(org_handle), do: ~p"/org/#{org_handle}"

def signed_in_path(%User{} = user) do
signed_in_path_from_context(User.last_context(user))
end

def signed_in_path(conn) do
case get_session(conn, :last_context) do
nil -> ~p"/home"
"personal" -> ~p"/home"
org_handle -> ~p"/org/#{org_handle}"
end
signed_in_path_from_context(get_session(conn, :last_context, User.default_context()))
end

defp login_code_ttl, do: 3600
Expand Down
6 changes: 6 additions & 0 deletions lib/algora_web/live/org/nav.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ defmodule AlgoraWeb.Org.Nav do
icon: "tabler-users",
label: "Team"
},
%{
href: "/org/#{org_handle}/transactions",
tab: :transactions,
icon: "tabler-credit-card",
label: "Transactions"
},
%{
href: "/org/#{org_handle}/analytics",
tab: :analytics,
Expand Down
Loading
Loading