summaryrefslogtreecommitdiff
path: root/users/app/controllers/controller_extension/authentication.rb
blob: 507b62fa415722e89845dd27af43db2ec6f32bba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module ControllerExtension::Authentication
  extend ActiveSupport::Concern

  private

  included do
    helper_method :current_user
  end

  def current_user
    @current_user ||= User.find(session[:user_id]) if session[:user_id]
  end

  def authorize
    redirect_to login_url, :alert => "Not authorized" if current_user.nil?
  end
end