Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ gem 'pandora_client' # Pandora Tuner API client
gem 'tire' # ElasticSearch adapter

# Async processing
gem 'sidekiq', git: 'https://github.com/mperham/sidekiq.git' # Threaded, Resque-compatible task queues
gem 'sidekiq' # Threaded, Resque-compatible task queues

# Authentication
gem 'devise'
gem 'omniauth-facebook'
gem 'omniauth-do'

# Front-end
gem 'haml', '3.2.0.alpha.8' # HTML pre-processor
Expand Down
129 changes: 77 additions & 52 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
GIT
remote: https://github.com/mperham/sidekiq.git
revision: 01bae6eef79d33438a489493b96a8f48f5bababe
specs:
sidekiq (0.6.0)
celluloid
connection_pool
multi_json
redis
redis-namespace

GEM
remote: http://rubygems.org/
specs:
Expand Down Expand Up @@ -42,6 +31,7 @@ GEM
multi_json (~> 1.0)
arel (2.2.1)
awesome_print (1.0.2)
bcrypt-ruby (3.0.1)
binding_of_caller (0.6.7)
builder (3.0.0)
capistrano (2.9.0)
Expand All @@ -50,30 +40,44 @@ GEM
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
celluloid (0.8.0)
celluloid (0.11.1)
timers (>= 1.0.0)
chunky_png (1.2.5)
coderay (1.0.6)
coderay (1.0.7)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
railties (~> 3.1.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.2.0)
columnize (0.3.6)
compass (0.12.alpha.0)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
connection_pool (0.1.0)
coolline (0.2.0)
connection_pool (0.9.2)
coolline (0.3.0)
crypt19 (1.2.1)
debugger (1.1.4)
columnize (>= 0.3.1)
debugger-linecache (~> 1.1.1)
debugger-ruby_core_source (~> 1.1.3)
debugger-linecache (1.1.2)
debugger-ruby_core_source (>= 1.1.1)
debugger-ruby_core_source (1.1.3)
devise (2.1.2)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (~> 3.1)
warden (~> 1.2.1)
diff-lcs (1.1.3)
diffy (2.0.6)
diffy (2.0.8)
ejs (1.0.0)
erubis (2.7.0)
execjs (1.3.0)
multi_json (~> 1.0)
faraday (0.8.0)
faraday (0.8.4)
multipart-post (~> 1.1)
foreigner (1.1.1)
activerecord (>= 3.0.0)
Expand All @@ -90,32 +94,35 @@ GEM
highline (1.6.11)
hike (1.2.1)
hirb (0.6.2)
hiredis (0.4.1)
hiredis (0.4.5)
httpauth (0.1)
i18n (0.6.0)
jazz_hands (0.2.0)
jazz_hands (0.3.1)
awesome_print (~> 1.0.2)
coderay (~> 1.0.5)
coderay (~> 1.0.6)
coolline (>= 0.1.0)
hirb (~> 0.6.2)
pry (~> 0.9.8.4)
pry-doc (~> 0.4.1)
pry-git (~> 0.2.2)
pry-nav (~> 0.2.0)
pry-remote (>= 0.1.1)
pry-stack_explorer (~> 0.4.1)
pry (~> 0.9.9)
pry-debugger (~> 0.2.0)
pry-doc (~> 0.4.2)
pry-git (~> 0.2.3)
pry-remote (>= 0.1.4)
pry-stack_explorer (~> 0.4.2)
railties (~> 3.0)
jquery-rails (1.0.18)
railties (~> 3.0)
thor (~> 0.14)
json (1.6.5)
json (1.7.3)
jwt (0.1.5)
multi_json (>= 1.0)
kgio (2.7.2)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
method_source (0.7.1)
mime-types (1.17.2)
multi_json (1.3.5)
mime-types (1.19)
multi_json (1.3.6)
multipart-post (1.1.5)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
Expand All @@ -125,17 +132,24 @@ GEM
net-ssh-gateway (1.1.0)
net-ssh (>= 1.99.1)
nokogiri (1.5.2)
oauth2 (0.5.2)
faraday (~> 0.7)
oauth2 (0.8.0)
faraday (~> 0.8)
httpauth (~> 0.1)
jwt (~> 0.1.4)
multi_json (~> 1.0)
omniauth (1.0.0)
rack (~> 1.2)
omniauth (1.1.1)
hashie (~> 1.2)
rack
omniauth-facebook (1.0.0)
omniauth-oauth2 (~> 1.0.0)
omniauth-oauth2 (1.0.0)
oauth2 (~> 0.5.0)
omniauth-do (1.0.0)
omniauth (~> 1.0)
omniauth-oauth2 (~> 1.1)
omniauth-facebook (1.4.1)
omniauth-oauth2 (~> 1.1.0)
omniauth-oauth2 (1.1.0)
oauth2 (~> 0.8.0)
omniauth (~> 1.0)
orm_adapter (0.4.0)
pandora_client (0.1.0)
crypt19 (~> 1.2.1)
faraday (~> 0.8)
Expand All @@ -144,27 +158,27 @@ GEM
pg (0.11.0)
polyglot (0.3.3)
posix-spawn (0.3.6)
pry (0.9.8.4)
pry (0.9.9.6)
coderay (~> 1.0.5)
method_source (~> 0.7.1)
slop (>= 2.4.4, < 3)
pry-doc (0.4.2)
pry (>= 0.9.0)
pry-debugger (0.2.0)
debugger (~> 1.1.3)
pry (~> 0.9.9)
pry-doc (0.4.4)
pry (>= 0.9.9.6)
yard (~> 0.8.1)
pry-git (0.2.3)
diffy
grit
pry (>= 0.9.8)
pry-nav (0.2.0)
pry (~> 0.9.8.1)
pry-remote (0.1.1)
pry (~> 0.9.8)
pry-remote (0.1.5)
pry (~> 0.9.9)
slop (~> 2.1)
pry-stack_explorer (0.4.1)
pry-stack_explorer (0.4.5)
binding_of_caller (~> 0.6.2)
pry (~> 0.9.8.2)
rack (1.3.6)
rack-cache (1.1)
rack-cache (1.2)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
Expand Down Expand Up @@ -197,9 +211,9 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
redis (2.2.2)
redis-namespace (1.1.0)
redis (< 3.0.0)
redis (3.0.1)
redis-namespace (1.2.0)
redis (~> 3.0.0)
rest-client (1.6.7)
mime-types (>= 1.16)
sass (3.1.10)
Expand All @@ -208,9 +222,15 @@ GEM
railties (~> 3.1.0)
sass (~> 3.1.10)
tilt (~> 1.3.2)
sidekiq (2.0.3)
celluloid (~> 0.11.0)
connection_pool (~> 0.9.0)
multi_json (~> 1)
redis (~> 3)
redis-namespace
slop (2.4.4)
springboard (0.18.7.1)
sprockets (2.0.3)
sprockets (2.0.4)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
Expand All @@ -219,6 +239,7 @@ GEM
term-ansicolor (1.0.7)
thor (0.14.6)
tilt (1.3.3)
timers (1.0.1)
tire (0.3.12)
activemodel (~> 3.0)
multi_json (~> 1.0)
Expand All @@ -235,7 +256,9 @@ GEM
kgio (~> 2.6)
rack
raindrops (~> 0.7)
yard (0.8.1)
warden (1.2.1)
rack (>= 1.0)
yard (0.8.2.1)

PLATFORMS
ruby
Expand All @@ -246,6 +269,7 @@ DEPENDENCIES
compass (= 0.12.alpha)
connection_pool
crypt19
devise
execjs
foreigner
foreman
Expand All @@ -254,6 +278,7 @@ DEPENDENCIES
jazz_hands
jquery-rails
nokogiri
omniauth-do
omniauth-facebook
pandora_client
patron
Expand All @@ -263,7 +288,7 @@ DEPENDENCIES
rails-behaviors
redis
sass-rails (~> 3.1.5)
sidekiq!
sidekiq
springboard
swfobject-rails
tire
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
worker: bundle exec sidekiq -q indexing,2 -q archiving,1 -c 10
push: cd push && npm run-script start
push: cd push && npm start
search: bundle exec springboard -c config/elasticsearch -f
18 changes: 0 additions & 18 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,4 @@ class ApplicationController < ActionController::Base

before_filter :authenticate_user!


def authenticate_user!
unless current_user
redirect_to login_url
end
end

def current_user
@current_user =
begin
if session[:user_id] && (user = User.find_by_id(session[:user_id]))
user
else
reset_session
nil
end
end
end
end
30 changes: 0 additions & 30 deletions app/controllers/sessions_controller.rb

This file was deleted.

34 changes: 34 additions & 0 deletions app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def login
auth = request.env['omniauth.auth']

# TODO: find or create by
@identity = Identity.find_with_omniauth(auth) || Identity.create_with_omniauth(auth)

# Account Linking
if signed_in?
# Account is already linked.
if @identity.user == current_user
redirect_to root_url
else
@identity.user = current_user
@identity.save
redirect_to root_url, notice: 'Sweet dood, you linked your account!'
end
else
if @identity.user.present?
sign_in @identity.user
redirect_to root_url
else
@identity.user = User.find_or_create_by_email_with_omniauth(auth['info'])
@identity.save
sign_in @identity.user
redirect_to root_url
end
end
end

alias :facebook :login
alias :do :login

end
10 changes: 10 additions & 0 deletions app/models/identity.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Identity < ActiveRecord::Base
belongs_to :user

def self.find_with_omniauth(auth)
find_by_provider_and_uid auth['provider'].to_s, auth['uid'].to_s
end
def self.create_with_omniauth(auth)
Identity.create(uid: auth['uid'].to_s, provider: auth['provider'].to_s)
end
end
Loading