4.15 added better login checking

This commit is contained in:
Aaro Koivukangas
2023-11-11 21:53:39 +02:00
parent 285ca9f694
commit 024c95031a
9 changed files with 14 additions and 8 deletions
@@ -5,4 +5,8 @@ class ApplicationController < ActionController::Base
User.find_by_id session[:user_id]
end
def ensure_that_signed_in
redirect_to signin_path, notice: 'you should be signed in' if current_user.nil?
end
end
+1
View File
@@ -1,5 +1,6 @@
class BeerclubsController < ApplicationController
before_action :set_beerclub, only: %i[show edit update destroy]
before_action :ensure_that_signed_in, except: [:index, :show]
# GET /beerclubs or /beerclubs.json
def index
+1
View File
@@ -1,6 +1,7 @@
class BeersController < ApplicationController
before_action :set_beer, only: %i[show edit update destroy]
before_action :set_breweries_and_styles_for_template, only: [:new, :edit, :create]
before_action :ensure_that_signed_in, except: [:index, :show]
# GET /beers or /beers.json
def index
+1 -1
View File
@@ -1,6 +1,6 @@
class BreweriesController < ApplicationController
before_action :set_brewery, only: %i[show edit update destroy]
before_action :authenticate, only: [:destroy]
before_action :ensure_that_signed_in, except: [:index, :show]
# GET /breweries or /breweries.json
def index