From 373d05e8def086c8d3a67f479c0973004ebe51e5 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Tue, 16 Nov 2021 10:24:47 +0200 Subject: [PATCH] Fix error with anonymous users on shared links --- lib/plausible_web/views/layout_view.ex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/plausible_web/views/layout_view.ex b/lib/plausible_web/views/layout_view.ex index ec2bb57da..bba14ea7b 100644 --- a/lib/plausible_web/views/layout_view.ex +++ b/lib/plausible_web/views/layout_view.ex @@ -55,11 +55,15 @@ defmodule PlausibleWeb.LayoutView do end end + def on_grace_period?(nil), do: false + def on_grace_period?(user) do user.grace_period && Timex.diff(user.grace_period.end_date, Timex.today(), :days) >= 0 end + def grace_period_over?(nil), do: false + def grace_period_over?(user) do user.grace_period && Timex.diff(user.grace_period.end_date, Timex.today(), :days) < 0