Created
September 26, 2013 01:26
-
-
Save Swelly/6708612 to your computer and use it in GitHub Desktop.
Omniauth callback with Twitter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group :development, :test do | |
gem 'rspec' | |
gem 'factory_girl_rails' | |
gem 'pry-rails' # Causes rails console to open pry | |
# https://github.com/rweng/pry-rails | |
gem 'pry-debugger' # Adds step, next, finish, and continue commands and breakpoints | |
# https://github.com/nixme/pry-debugger | |
gem 'pry-stack_explorer' # Navigate the call-stack | |
# https://github.com/pry/pry-stack_explorer | |
gem 'annotate' # Annotate all your models, tests, fixtures, and factories | |
# https://github.com/ctran/annotate_models | |
gem 'quiet_assets' # Turns off the Rails asset pipeline log | |
# https://github.com/evrone/quiet_assets | |
# gem 'better_errors' # Replaces the standard Rails error page with a much better and more useful error page | |
# https://github.com/charliesome/better_errors | |
gem 'binding_of_caller' # Advanced features for better_errors advanced features (REPL, local/instance variable inspection, pretty stack frame names) | |
# https://github.com/banister/binding_of_caller | |
gem 'meta_request' # Supporting gem for Rails Panel (Google Chrome extension for Rails development). | |
# https://github.com/dejan/rails_panel/tree/master/meta_request | |
gem 'rails-erd' # Diagrams your models. NOTE! $ brew install graphviz | |
# https://github.com/voormedia/rails-erd | |
gem 'rspec-rails', '~> 2.0' # Rspec-rails is a testing framework for Rails 3.x and 4.x. | |
gem 'dotenv-rails' # $touch .env | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OmniauthCallbacksController < Devise::OmniauthCallbacksController | |
def twitter | |
# You need to implement the method below in your model (e.g. app/models/user.rb) | |
@user = User.find_for_twitter_oauth(request.env["omniauth.auth"], current_user) | |
if @user.persisted? | |
sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated | |
set_flash_message(:notice, :success, :kind => "Twitter") if is_navigational_format? | |
else | |
session["devise.twitter_data"] = request.env["omniauth.auth"] | |
redirect_to new_user_registration_url | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment