daitokai/daitokaiet

View on GitHub
app/controllers/users/omniauth_callbacks_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
  def twitter
    # You need to implement the method below in your model
    @user = User.find_for_twitter_oauth(request.env['omniauth.auth'], current_user)

    if @user.persisted?
      set_flash_message(:notice, :success, :kind => 'Twitter') if is_navigational_format?
      sign_in_and_redirect @user, :event => :authentication
    else
      session['devise.twitter_data'] = request.env['omniauth.auth'].except('extra')
      redirect_to new_user_registration_url
    end
  end

  def after_sign_in_path_for(user)
    if user.step == 0
      flash[:notice] = '#daitokaietへようこそ!最初に目標体重を設定してください。'
      edit_user_registration_path
    else
      super
    end
  end

end