Module: OmniAuth::Infinum::Controller::InstanceMethods

Defined in:
lib/omniauth-infinum/controller.rb

Instance Method Summary collapse

Instance Method Details

#authenticate_user!Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/omniauth-infinum/controller.rb', line 3

def authenticate_user!
  if current_user.blank?
    respond_to do |format|
      format.html  {
        redirect_to "/auth/infinum?origin=#{request.url}"
      }
      format.json {
        render :json => { 'error' => 'Access Denied' }.to_json
      }
    end
  end
end

#current_userObject



16
17
18
19
20
# File 'lib/omniauth-infinum/controller.rb', line 16

def current_user
  return nil unless session[:user_id]

  @current_user ||= User.new_from_omniauth(session[:user_id])
end