Fix error with multiple invitations

The /activate page would error out when the user had more than 1
invitation. Will work as expected now. Fixes #1147
pull/1169/head
Uku Taht 5 years ago
parent 46f6942be1
commit 388fc39d5e

@ -134,7 +134,11 @@ defmodule PlausibleWeb.AuthController do
def activate_form(conn, _params) do
user = conn.assigns[:current_user]
invitation = Repo.get_by(Plausible.Auth.Invitation, email: user.email)
has_invitation = Repo.exists?(
from i in Plausible.Auth.Invitation,
where: i.email == ^user.email
)
has_code =
Repo.exists?(
@ -144,7 +148,7 @@ defmodule PlausibleWeb.AuthController do
render(conn, "activate.html",
has_pin: has_code,
invitation: invitation,
has_invitation: has_invitation,
layout: {PlausibleWeb.LayoutView, "focus.html"}
)
end

@ -47,7 +47,7 @@
</div>
<% end %>
<%= if !@invitation do %>
<%= if !@has_invitation do %>
<div class="pt-12 pl-8 hidden md:block">
<%= render(PlausibleWeb.AuthView, "_onboarding_steps.html", current_step: 1) %>
</div>

@ -7,7 +7,7 @@
<% end %>
</header>
<div class="flow-root mt-6">
<ul class="-my-5 divide-y divide-gray-200">
<ul class="-my-5 divide-y divide-gray-200 dark:divide-gray-50">
<%= for membership <- @site.memberships do %>
<li class="py-4">
<div class="flex items-center space-x-4">
@ -15,7 +15,7 @@
<%= gravatar(membership.user.email, class: "h-8 w-8 rounded-full") %>
</div>
<div class="flex-1 min-w-0">
<p class="text-sm font-medium text-gray-900 truncate">
<p class="text-sm font-medium text-gray-900 dark:text-gray-50 truncate">
<%= membership.user.name %>
</p>
<p class="text-sm text-gray-500 truncate">

Loading…
Cancel
Save