Module: AuthPassportCheckpoint::CurrentUserHelper::ForIntermediaryApi

Defined in:
lib/auth_passport_checkpoint/helpers/controller_helpers/current_user_helper.rb

Instance Method Summary collapse

Instance Method Details

#current_userObject



15
16
17
18
19
20
21
# File 'lib/auth_passport_checkpoint/helpers/controller_helpers/current_user_helper.rb', line 15

def current_user
  return @current_user if @current_user 
  if result = user_signed_request_result(AuthPassportCheckpoint.current_user_url)
    return @current_user ||= OpenStruct.new(result)
  end        
  nil
end

#login_requiredObject



4
5
6
7
8
9
10
11
12
13
# File 'lib/auth_passport_checkpoint/helpers/controller_helpers/current_user_helper.rb', line 4

def      
  if !current_user
    error = { 'error' => '401 Unauthorized', 'status' => 401 }
    if Object.const_defined?("Grape") and self.class == Grape::Endpoint
      error!('401 Unauthorized', 401)
    else
      render :json => error.to_json
    end
  end
end