Module: AuPair::Authenticates

Defined in:
lib/au_pair/authenticates.rb

Instance Method Summary collapse

Instance Method Details

#authenticate!Object



11
12
13
14
# File 'lib/au_pair/authenticates.rb', line 11

def authenticate!
  return true if AuPair::AuthenticationToken.valid?(token, vendor_name)
  render(:json => {'error' => 'Invalid authentication token.'}, :status => 401) and return
end

#tokenObject



3
4
5
# File 'lib/au_pair/authenticates.rb', line 3

def token
  request.headers['x-api-token'] || params[:api_token]
end

#vendor_nameObject



7
8
9
# File 'lib/au_pair/authenticates.rb', line 7

def vendor_name
  request.headers['x-api-vendor'] || params[:api_vendor]
end