View educations_controller.rb
def linkedin | |
@user=current_user | |
client = LinkedIn::Client.new("API Key", "Secret Key") | |
client.authorize_from_access(current_user.link_token, current_user.link_secret) | |
#breakdown LinkedIn Hash into pieces in order to obtain data | |
@profile = client.profile | |
@school = client.profile(:fields => %w(educations)) | |
@schools = @school.educations.all.map{|t| t} | |
View api.rb
before do | |
client = Client.active.find_by(token: headers["Auth-Token"]) | |
error!('Unauthorized. Invalid token.', 401) unless client | |
error!('Unauthorized action.', 403) unless client.user_authorization_required? && User.new(headers["X-Grpn-Email"]).authorized_action?(request.request_method) | |
end |
View redis.rb
if ENV['REDIS_ACCESS_MODE'] == 'readonly' | |
class Redis | |
class Client | |
WRITE_COMMANDS = ::Rails.cache.data.command.map { |a| a[0] if a[2].include?('write') }.compact.to_set.freeze | |
def process(commands) | |
if commands.flatten.any? { |c| WRITE_COMMANDS.include?(c.to_s) } | |
raise NotImplementedError, "REDIS_ACCESS_MODE is set to 'readonly', disallowing writes" | |
end |
View yay.rb
respond_to do |format| | |
format.json { render :json => { :success => true, :message => 'yay' } } | |
end |