Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Commit

Permalink
partially implemented twitter omniauth
Browse files Browse the repository at this point in the history
  • Loading branch information
bdougie committed Mar 3, 2014
1 parent 42640b6 commit 9aea857
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ gem 'sunspot_rails'
gem 'progress_bar' # added for sunspot
#login gems
gem 'omniauth-facebook'
gem 'omniauth-twitter'

#assets
gem 'sass-rails', '~> 4.0.0'
Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ GEM
net-ssh (2.7.0)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
oauth (0.4.7)
oauth2 (0.9.3)
faraday (>= 0.8, < 0.10)
jwt (~> 0.1.8)
Expand All @@ -125,11 +126,17 @@ GEM
rack (~> 1.0)
omniauth-facebook (1.6.0)
omniauth-oauth2 (~> 1.1)
omniauth-oauth (1.0.1)
oauth
omniauth (~> 1.0)
omniauth-oauth2 (1.1.2)
faraday (>= 0.8, < 0.10)
multi_json (~> 1.3)
oauth2 (~> 0.9.3)
omniauth (~> 1.2)
omniauth-twitter (1.0.1)
multi_json (~> 1.3)
omniauth-oauth (~> 1.0)
options (2.3.2)
orm_adapter (0.5.0)
pg (0.17.1)
Expand Down Expand Up @@ -237,6 +244,7 @@ DEPENDENCIES
jquery-rails
mini_magick
omniauth-facebook
omniauth-twitter
pg
progress_bar
rails (= 4.0.0)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def after_sign_in_path_for(resource)
private

def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) << [:avatar, :name, :email, :password, :password_confirmation,
devise_parameter_sanitizer.for(:sign_up) << [:avatar, :name, :email, :username, :password, :password_confirmation,
:remember_me, :provider, :uid]
devise_parameter_sanitizer.for(:account_update) << [:avatar, :name, :username]
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def index


private
# strong params are in the ApplicationController
# #parameters for users
# def configure_permitted_parameters
# devise_parameter_sanitizer.for(:sign_up) << :name
Expand Down
7 changes: 6 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ class User < ActiveRecord::Base
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable,
:omniauthable, :omniauth_providers => [:facebook]
:omniauthable, #:omniauth_providers => [:facebook], :omniauth_providers => [:twitter],

# vthese validations are throwing errors.
# validates :email, presence: true
validates :username, presence: true
validates :username, uniqueness: true

mount_uploader :avatar, AvatarUploader

def self.find_for_facebook_oauth(auth, signed_in_resource=nil)
Expand All @@ -16,6 +20,7 @@ def self.find_for_facebook_oauth(auth, signed_in_resource=nil)
provider: auth.provider,
uid: auth.uid,
email: auth.info.email,
# avatar: auth.image,
password: pass,
password_confirmation: pass
)
Expand Down
1 change: 1 addition & 0 deletions config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,5 @@
# so you need to do it manually. For the users scope, it would be:
# config.omniauth_path_prefix = '/my_engine/users/auth'
config.omniauth :facebook, ENV['FACEBOOK_ID'], ENV['FACEBOOK_SECRET']
config.omniauth :twitter, ENV["TWITTER_CONSUMER_KEY"], ENV["TWITTER_CONSUMER_SECRET"]
end
5 changes: 3 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
get "church/edit"
get "church/new"

devise_for :users, controllers: {omniauth_callbacks:'users/omniauth_callbacks'}

# devise_for :users, controllers: {omniauth_callbacks:'users/omniauth_callbacks'}
# added the below for twitter
devise_for :users, path_names: {sign_in: "login", sign_out: "logout"}, controllers: {omniauth_callbacks: "omniauth_callbacks"}

end

0 comments on commit 9aea857

Please sign in to comment.