2012-01-30 20:39:34 +00:00
|
|
|
# -*- encoding : utf-8 -*-
|
2012-05-02 10:18:07 +01:00
|
|
|
class Platforms::PrivatesController < Platforms::BaseController
|
2011-10-18 14:47:17 +01:00
|
|
|
require 'digest/sha2'
|
|
|
|
|
|
|
|
before_filter :find_platform
|
|
|
|
before_filter :authenticate
|
|
|
|
|
|
|
|
def show
|
2011-11-02 12:39:04 +00:00
|
|
|
file_name = "#{APP_CONFIG['root_path']}/platforms/#{params[:platform_name]}/#{params[:file_path]}"
|
2011-10-18 14:47:17 +01:00
|
|
|
|
|
|
|
if File.directory?(file_name) || !File.exists?(file_name)
|
|
|
|
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
|
|
|
else
|
|
|
|
send_file file_name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def authenticate
|
|
|
|
authenticate_or_request_with_http_basic do |username, password|
|
|
|
|
PrivateUser.exists?(
|
|
|
|
:login => username,
|
|
|
|
:password => Digest::SHA2.new.hexdigest(password),
|
|
|
|
:platform_id => @platform.try(:id)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_platform
|
|
|
|
@platform = Platform.find_by_name(params[:platform_name])
|
|
|
|
end
|
|
|
|
end
|