Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fix app links & invitation error #316

Merged
merged 2 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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 @@ -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