41 lines
1009 B
Ruby
41 lines
1009 B
Ruby
|
|
class ActivationsController < ApplicationController
|
||
|
|
|
||
|
|
skip_before_filter :verify_authenticity_token
|
||
|
|
|
||
|
|
before_filter :authenticate
|
||
|
|
before_filter :init_params, :only => :create
|
||
|
|
|
||
|
|
def create
|
||
|
|
@activation = Activation.new(params[:activation])
|
||
|
|
|
||
|
|
if @activation.save
|
||
|
|
respond_to do |format|
|
||
|
|
format.xml { render_activation_xml }
|
||
|
|
end
|
||
|
|
else
|
||
|
|
FailedActivation.create_from_activation(@activation)
|
||
|
|
respond_to do |format|
|
||
|
|
format.xml { render_activation_xml }
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
private
|
||
|
|
|
||
|
|
def render_activation_xml
|
||
|
|
render :xml => @activation.to_xml(:buy_url => order_url(featured_product), :support_url => support_contact_url)
|
||
|
|
end
|
||
|
|
|
||
|
|
def init_params
|
||
|
|
params[:activation] ||= {}
|
||
|
|
params[:activation][:ip] = request.remote_ip
|
||
|
|
end
|
||
|
|
|
||
|
|
def authenticate
|
||
|
|
authenticate_or_request_with_http_basic do |login, password|
|
||
|
|
login == Settings.activation_auth.login && password == Settings.activation_auth.password
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
end
|