From d5e79a208349588eda8e745d3e2e56d3a4df98c8 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Fri, 25 Jun 2021 12:00:15 +0300 Subject: [PATCH] fix assign --- lib/plausible_web/controllers/auth_controller.ex | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/plausible_web/controllers/auth_controller.ex b/lib/plausible_web/controllers/auth_controller.ex index de2b5d57b..56e7c1e97 100644 --- a/lib/plausible_web/controllers/auth_controller.ex +++ b/lib/plausible_web/controllers/auth_controller.ex @@ -156,12 +156,16 @@ defmodule PlausibleWeb.AuthController do def activate(conn, %{"code" => code}) 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 + ) {code, ""} = Integer.parse(code) case Auth.verify_email(user, code) do :ok -> - if invitation do + if has_invitation do redirect(conn, to: "/sites") else redirect(conn, to: "/sites/new") @@ -171,7 +175,7 @@ defmodule PlausibleWeb.AuthController do render(conn, "activate.html", error: "Incorrect activation code", has_pin: true, - invitation: invitation, + has_invitation: has_invitation, layout: {PlausibleWeb.LayoutView, "focus.html"} ) @@ -179,7 +183,7 @@ defmodule PlausibleWeb.AuthController do render(conn, "activate.html", error: "Code is expired, please request another one", has_pin: false, - invitation: invitation, + has_invitation: has_invitation, layout: {PlausibleWeb.LayoutView, "focus.html"} ) end