Check authentication on each request #26
2 changed files with 2 additions and 2 deletions
|
@ -8,6 +8,6 @@ module Authenticatable
|
||||||
private
|
private
|
||||||
|
|
||||||
def authenticate_user
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<li class="mr-6"><%= link_to "Credit Card Bills", credit_card_bills_path, class: "text-white" %></li>
|
<li class="mr-6"><%= link_to "Credit Card Bills", credit_card_bills_path, class: "text-white" %></li>
|
||||||
<li class="mr-6"><%= link_to "Incomes", incomes_path, class: "text-white" %></li>
|
<li class="mr-6"><%= link_to "Incomes", incomes_path, class: "text-white" %></li>
|
||||||
<li class="mr-6"><%= link_to "Members", members_path, class: "text-white" %></li>
|
<li class="mr-6"><%= link_to "Members", members_path, class: "text-white" %></li>
|
||||||
<% if Current.user %>
|
<% if Current.user.registered? %>
|
||||||
<li class="mr-6"><%= link_to "Log out", session_path, data: {turbo_method: :delete}, class: "text-white" %></li>
|
<li class="mr-6"><%= link_to "Log out", session_path, data: {turbo_method: :delete}, class: "text-white" %></li>
|
||||||
<% else %>
|
<% else %>
|
||||||
<li class="mr-6"><%= link_to "Log in", new_session_path, class: "text-white" %></li>
|
<li class="mr-6"><%= link_to "Log in", new_session_path, class: "text-white" %></li>
|
||||||
|
|
Loading…
Reference in a new issue