Skip to content

Commit

Permalink
Implement meetup oauth for login
Browse files Browse the repository at this point in the history
Deprecate linking of meetup accounts to associate with old workshops from meetup

Remove 'connect with meetup!!!' prompt
  • Loading branch information
tjgrathwell committed Mar 19, 2014
1 parent 11cbc54 commit fdcf950
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 63 deletions.
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ To import historical data from Meetup, use the rake task `rake meetup:import`. T
#### Meetup OAuth
To test authenticating with Meetup using your localhost server, you need to [register a new OAuth Consumer at Meetup](http://www.meetup.com/meetup_api/oauth_consumers/).

When you add a new OAuth consumer, set the _Website_ as `http://bridgetroll.herokuapp.com`, the _Redirect URI_ as `http://localhost:3000/auth/meetup/callback`, and the _De-authorization Notification URL_ as `http://localhost:3000/auth/meetup/destroy`.
When you add a new OAuth consumer, set the _Website_ as `http://www.bridgetroll.org`, the _Redirect URI_ as `http://localhost:3000/users/auth/meetup/callback`.

The values for _key_ and _secret_ on the OAuth consumers page should be added to your local environment as MEETUP_OAUTH_KEY and MEETUP_OAUTH_SECRET, respectively.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def all
redirect_to new_user_registration_path
end
end
[:facebook, :twitter, :github].each do |provider|
[:facebook, :twitter, :github, :meetup].each do |provider|
alias_method provider, :all
end
end
9 changes: 0 additions & 9 deletions app/controllers/users/meetup_prompts_controller.rb

This file was deleted.

20 changes: 0 additions & 20 deletions app/models/meetup_prompt.rb

This file was deleted.

11 changes: 11 additions & 0 deletions app/services/omniauth_providers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ def self.provider_data
key: :github,
name: 'Github',
icon: 'fa-github-square'
},
{
key: :meetup,
name: 'Meetup',
icon: 'fa-calendar'
}
]
end
Expand All @@ -30,6 +35,8 @@ def self.user_attributes_from_omniauth(omniauth)
self.twitter_omniauth_attributes(omniauth)
elsif omniauth['provider'] == 'github'
self.github_omniauth_attributes(omniauth)
elsif omniauth['provider'] == 'meetup'
self.meetup_omniauth_attributes(omniauth)
end
end

Expand Down Expand Up @@ -62,4 +69,8 @@ def self.github_omniauth_attributes(omniauth)
email: omniauth['info']['email']
)
end

def self.meetup_omniauth_attributes(omniauth)
self.split_name(omniauth['info']['name'])
end
end
1 change: 0 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<%= msg %>
</div>
<% end %>
<%= render partial: 'users/meetup_prompt' %>
<%= yield %>
<%= yield :scripts %>
Expand Down
8 changes: 0 additions & 8 deletions app/views/users/_meetup_prompt.html.erb

This file was deleted.

1 change: 1 addition & 0 deletions config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,5 @@
config.omniauth :facebook, ENV['FACEBOOK_OAUTH_KEY'], ENV['FACEBOOK_OAUTH_SECRET'], {scope: 'email'}
config.omniauth :twitter, ENV['TWITTER_OAUTH_KEY'], ENV['TWITTER_OAUTH_SECRET']
config.omniauth :github, ENV['GITHUB_OAUTH_KEY'], ENV['GITHUB_OAUTH_SECRET']
config.omniauth :meetup, ENV['MEETUP_OAUTH_KEY'], ENV['MEETUP_OAUTH_SECRET']
end
3 changes: 0 additions & 3 deletions config/initializers/omniauth.rb

This file was deleted.

1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

resources :users, only: [:index] do
resource :profile, :only => [:edit, :update, :show]
resource :meetup_prompt, :only => [:destroy], :controller => 'users/meetup_prompts'
end
resources :meetup_users, :only => [:show]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class RemoveMeetupPromptDismissedFlag < ActiveRecord::Migration
def up
remove_column :users, :meetup_prompt_dismissed
end

def down
add_column :users, :meetup_prompt_dismissed, :boolean
end
end
19 changes: 9 additions & 10 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20140303032651) do
ActiveRecord::Schema.define(:version => 20140319062825) do

create_table "authentications", :force => true do |t|
t.integer "user_id"
Expand Down Expand Up @@ -199,30 +199,29 @@
end

create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "admin", :default => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "admin", :default => false
t.string "first_name"
t.string "last_name"
t.integer "meetup_id"
t.string "time_zone"
t.boolean "meetup_prompt_dismissed"
t.string "gender"
t.boolean "allow_event_email", :default => true
t.boolean "publisher", :default => false
t.boolean "allow_event_email", :default => true
t.boolean "publisher", :default => false
end

add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true
Expand Down
9 changes: 0 additions & 9 deletions spec/features/homepage_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,5 @@
page.should_not have_link("Sign Up")
page.should have_link("Profile")
end

it 'is prompted to connect their meetup account' do
visit '/'
within '.alert' do
page.should have_link 'Connect to Meetup.com'
click_button '×'
end
page.should_not have_link 'Connect to Meetup.com'
end
end
end
27 changes: 27 additions & 0 deletions spec/features/omniauth_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,33 @@
end
end

context "with a valid meetup auth" do
let(:meetup_response) { OmniauthResponses.meetup_response }

before do
OmniAuth.config.mock_auth[:meetup] = OmniAuth::AuthHash.new(meetup_response)
end

it 'creates a user and authentication after the user provides an email' do
visit user_omniauth_authorize_path(:meetup)

within '#sign-up' do
fill_in 'Email', with: 'meetup_user@example.com'
end

click_on 'Sign up'

user = User.last
user.first_name.should == "Franz"
user.last_name.should == "Meetuper"
user.email.should == "meetup_user@example.com"

authentication = user.authentications.first
authentication.provider.should == 'meetup'
authentication.uid.should == meetup_response['uid'].to_s
end
end

context "with a valid github auth" do
let(:github_response) { OmniauthResponses.github_response }

Expand Down

0 comments on commit fdcf950

Please sign in to comment.