panter/mykonote

View on GitHub
app/controllers/authenticated_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

class AuthenticatedController < ApplicationController
  include Pundit::Authorization

  before_action :authenticate_user!
  before_action :set_paper_trail_whodunnit

  after_action :verify_authorized

  rescue_from Pundit::NotAuthorizedError do
    flash[:alert] = t('unauthorized')

    if user_signed_in?
      redirect_to :root
    else
      redirect_to new_user_session_path
    end
  end
end