From afb025f16cd19cbbdb2e65ef0551d507fbf6adc0 Mon Sep 17 00:00:00 2001 From: Andrzej Krzywda Date: Sun, 7 Jan 2024 17:56:11 +0100 Subject: [PATCH] Moved logged_in check to Rails filter --- .../app/controllers/client/orders_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rails_application/app/controllers/client/orders_controller.rb b/rails_application/app/controllers/client/orders_controller.rb index 2c13bea7e..e2a86f943 100644 --- a/rails_application/app/controllers/client/orders_controller.rb +++ b/rails_application/app/controllers/client/orders_controller.rb @@ -3,11 +3,16 @@ class OrdersController < ApplicationController layout 'client_panel' - def index + before_action :ensure_logged_in + + def ensure_logged_in if ClientOrders::Client.find_by(uid: cookies[:client_id]).nil? redirect_to logout_path return end + end + + def index render html: ClientOrders::OrdersList.build(view_context, cookies[:client_id]), layout: true end