From 455a20283e1f0a7ddeac2305eb8f3682ccf5ba82 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Fri, 16 Aug 2024 19:53:02 -0400 Subject: [PATCH] Check registered for session links --- app/controllers/concerns/authenticatable.rb | 2 +- app/views/layouts/application.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/concerns/authenticatable.rb b/app/controllers/concerns/authenticatable.rb index 9314cc9..492f5ce 100644 --- a/app/controllers/concerns/authenticatable.rb +++ b/app/controllers/concerns/authenticatable.rb @@ -8,6 +8,6 @@ module Authenticatable private def authenticate_user - Current.user = User.find_by(id: session[:current_user_id]) + Current.user = User.find_by(id: session[:current_user_id]) || GuestUser.new end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index fb838b8..a4b84df 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -19,7 +19,7 @@
  • <%= link_to "Credit Card Bills", credit_card_bills_path, class: "text-white" %>
  • <%= link_to "Incomes", incomes_path, class: "text-white" %>
  • <%= link_to "Members", members_path, class: "text-white" %>
  • - <% if Current.user %> + <% if Current.user.registered? %>
  • <%= link_to "Log out", session_path, data: {turbo_method: :delete}, class: "text-white" %>
  • <% else %>
  • <%= link_to "Log in", new_session_path, class: "text-white" %>