Skip to content

Commit

Permalink
Fixed bug when returning from Questionnaire, anonymous user was logge…
Browse files Browse the repository at this point in the history
…d out
  • Loading branch information
mellelieuwes committed Oct 2, 2024
1 parent 8f1b913 commit a0308c4
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/systems/account/_plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Systems.Account.Plug do
import Plug.Conn
alias Systems.Account

@valid_participant_path ~r"^\/assignment\/\d.*$"
@valid_participant_path ~r"^\/assignment\/(callback\/)?\d.*$"

@impl true
def init(opts), do: opts
Expand Down
5 changes: 5 additions & 0 deletions core/systems/assignment/_public.ex
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ defmodule Systems.Assignment.Public do
|> Repo.preload(preload)
end

def get_by_workflow_item_id(workflow_item_id, preload \\ []) do
%{workflow_id: workflow_id} = Workflow.Public.get_item!(String.to_integer(workflow_item_id))
Assignment.Public.get_by(:workflow_id, workflow_id, preload)
end

def get_by_tool_ref(workflow, preload \\ [])

def get_by_tool_ref(%Workflow.ToolRefModel{id: id}, preload), do: get_by_tool_ref(id, preload)
Expand Down
2 changes: 1 addition & 1 deletion core/systems/assignment/_queries.ex
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ defmodule Systems.Assignment.Queries do
end

def participant_query() do
from(Crew.MemberModel, as: :member)
from(Crew.MemberModel, as: :member, order_by: [asc: :public_id])
end

def participant_query(%Assignment.Model{crew: %{id: id, auth_node_id: auth_node_id}}) do
Expand Down
2 changes: 1 addition & 1 deletion core/systems/assignment/_routes.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule Systems.Assignment.Routes do
get("/assignment/:id/invite", Controller, :invite)
get("/assignment/:id/apply", Controller, :apply)
get("/assignment/:id/export", Controller, :export)
get("/assignment/callback/:item", Controller, :callback)
get("/assignment/callback/:workflow_item_id", Controller, :callback)
end

scope "/assignment", Systems.Assignment.Centerdata do
Expand Down
2 changes: 1 addition & 1 deletion core/systems/assignment/controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule Systems.Assignment.Controller do
@progress_yes dgettext("eyra-assignment", "progress.yes")
@progress_no dgettext("eyra-assignment", "progress.no")

def callback(%{assigns: %{current_user: user}} = conn, %{"item" => item_id}) do
def callback(%{assigns: %{current_user: user}} = conn, %{"workflow_item_id" => item_id}) do
%{workflow_id: workflow_id} = item = Workflow.Public.get_item!(String.to_integer(item_id))

%{id: id, crew: crew} =
Expand Down
4 changes: 4 additions & 0 deletions core/systems/project/branch_plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ defmodule Systems.Project.BranchPlug do
end

defp branch(["/", "storage", "endpoint", id | _]), do: branch(Storage.Public.get_endpoint!(id))

defp branch(["/", "assignment", "callback", workflow_item_id | _]),
do: branch(Assignment.Public.get_by_workflow_item_id(workflow_item_id))

defp branch(["/", "assignment", id | _]), do: branch(Assignment.Public.get(id))

defp branch(%{} = leaf) do
Expand Down

0 comments on commit a0308c4

Please sign in to comment.