Add authorization via headers. Posts go to the right place for forms.
This commit is contained in:
parent
91b451180a
commit
0fe6a71380
@ -7,14 +7,26 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
private
|
||||
|
||||
def authenticate_user_from_token!
|
||||
user_email = params[:user_email].presence
|
||||
user = user_email && User.find_by_email(user_email)
|
||||
|
||||
if user && Devise.secure_compare(user.authentication_token, params[:user_token])
|
||||
sign_in user, store:false
|
||||
def authenticate_user_from_token!
|
||||
if request.headers["HTTP_AUTHORIZATION"]
|
||||
authenticate_or_request_with_http_token do |token, options|
|
||||
email = token.split[1].split("=")[1]
|
||||
token = token.split[0]
|
||||
user_email = email.presence
|
||||
|
||||
user = user_email && User.find_by_email(user_email)
|
||||
if user && Devise.secure_compare(user.authentication_token, token)
|
||||
sign_in user, store:false
|
||||
end
|
||||
end
|
||||
else
|
||||
user_email = params[:user_email].presence
|
||||
token = params[:user_token]
|
||||
user = user_email && User.find_by_email(user_email)
|
||||
if user && Devise.secure_compare(user.authentication_token, token)
|
||||
sign_in user, store:false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
@ -15,9 +15,12 @@ class CampaignsController < ApplicationController
|
||||
def new
|
||||
@campaign = Campaign.new
|
||||
@campaign.videolistings.build
|
||||
@action = campaigns_path
|
||||
end
|
||||
|
||||
def edit
|
||||
@action = campaign_path(@campaign.clientid)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
@ -7,4 +7,9 @@ class Campaign < ActiveRecord::Base
|
||||
validates :advertisername, presence: true
|
||||
validates :websiteurl, presence: true
|
||||
|
||||
after_create :send_to_better_video
|
||||
def send_to_better_video
|
||||
#TODO Make API Calls
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -1,4 +1,4 @@
|
||||
<%= simple_form_for(@campaign, url: campaign_path(@campaign.clientid), html: {class: 'form-horizontal'}) do |frm| %>
|
||||
<%= simple_form_for(@campaign, url: @action, html: {class: 'form-horizontal'}) do |frm| %>
|
||||
<div class="row">
|
||||
<div class="col-md-1"></div>
|
||||
|
||||
|
5
db/migrate/20140415174406_add_sent_to_campaigns.rb
Normal file
5
db/migrate/20140415174406_add_sent_to_campaigns.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddSentToCampaigns < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :campaigns, :sent, :boolean, default: false
|
||||
end
|
||||
end
|
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140415165549) do
|
||||
ActiveRecord::Schema.define(version: 20140415174406) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@ -55,6 +55,7 @@ ActiveRecord::Schema.define(version: 20140415165549) do
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.boolean "processed"
|
||||
t.boolean "sent", default: false
|
||||
end
|
||||
|
||||
create_table "delayed_jobs", force: true do |t|
|
||||
|
Loading…
Reference in New Issue
Block a user