Skip to content

Commit

Permalink
feat: fix app links & invitation error (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
pichoemr authored Jan 3, 2023
1 parent 0ed5027 commit 16094b9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
19 changes: 11 additions & 8 deletions apps/lenra/lib/lenra/apps.ex
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,17 @@ defmodule Lenra.Apps do
|> UserEnvironmentAccess.changeset(%{user_id: user.id})
|> Repo.update()

Repo.one(
from(a in App,
join: e in Environment,
on: e.application_id == a.id,
where: e.id == ^access.environment_id,
select: a.service_name
service_name =
Repo.one(
from(a in App,
join: e in Environment,
on: e.application_id == a.id,
where: e.id == ^access.environment_id,
select: a.service_name
)
)
)

{:ok, %{app_name: service_name}}
else
false -> BusinessError.invitation_wrong_email(:wrong_email)
err -> err
Expand Down Expand Up @@ -349,7 +352,7 @@ defmodule Lenra.Apps do

defp add_invitation_events(app, user_access, email) do
lenra_app_url = Application.fetch_env!(:lenra, :lenra_app_url)
invitation_link = "#{lenra_app_url}/app/invitation/#{user_access.id}"
invitation_link = "#{lenra_app_url}/#/app/invitations/#{user_access.id}"

EmailWorker.add_email_invitation_event(email, app.name, invitation_link)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defmodule Lenra.UserEnvironmentAccessServicesTest do
alias Lenra.Apps
alias Lenra.Apps.{App, Environment}

@app_url_prefix "https://localhost:10000/app/invitation"
@app_url_prefix "https://localhost:10000/#/app/invitations"

setup do
{:ok, create_and_return_application()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ defmodule LenraWeb.UserEnvironmentAccessController do

def accept(conn, %{"id" => id}) do
with user <- Guardian.Plug.current_resource(conn),
app_name <- Apps.accept_invitation(id, user) do
{:ok, res} <- Apps.accept_invitation(id, user) do
conn
|> reply(%{app_name: app_name})
|> reply(res)
end
end

Expand Down

0 comments on commit 16094b9

Please sign in to comment.