Module: AuthPassportCheckpoint::IntermediaryApi::CurrentUserHelper

Included in:
Helper
Defined in:
lib/auth_passport_checkpoint/intermediary_api/current_user_helper.rb

Instance Method Summary collapse

Instance Method Details

#current_userObject



16
17
18
19
# File 'lib/auth_passport_checkpoint/intermediary_api/current_user_helper.rb', line 16

def current_user
  result = signed_request_result(AuthPassportCheckpoint.current_user_url)
  @current_user ||= result.try(:[],:error) ? nil : result
end

#login_requiredObject



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

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