add ability to get my channels via API
This commit is contained in:
@ -53,6 +53,16 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
end
|
||||
|
||||
# authenticates user based on the user's api_key
|
||||
def authenticate_via_api_key!
|
||||
# exit if no api_key
|
||||
return false if params[:api_key].blank?
|
||||
# get the user
|
||||
user = User.find_by_api_key(params[:api_key])
|
||||
# sign in the user if they exist
|
||||
sign_in(user, store: false) if user.present?
|
||||
end
|
||||
|
||||
# get the locale, but don't fail if header value doesn't exist
|
||||
def get_locale
|
||||
locale = get_header_value('HTTP_ACCEPT_LANGUAGE')
|
||||
|
@ -1,5 +1,6 @@
|
||||
class ChannelsController < ApplicationController
|
||||
include ChannelsHelper, ApiKeys
|
||||
before_filter :authenticate_via_api_key!, :only => [:index]
|
||||
before_filter :require_user, :except => [:realtime, :realtime_update, :show, :post_data, :social_show, :social_feed, :public]
|
||||
before_filter :set_channels_menu
|
||||
layout 'application', :except => [:social_show, :social_feed]
|
||||
@ -140,7 +141,8 @@ class ChannelsController < ApplicationController
|
||||
@channels = current_user.channels
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render :json => @channels.to_json(:root => false) }
|
||||
format.json { render :json => @channels.to_json(Channel.private_options) }
|
||||
format.xml { render :xml => @channels.to_xml(Channel.private_options) }
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user