# Class: Users::OmniauthCallbacksController

Inherits:
  Devise::OmniauthCallbacksController
  - Object
  - Devise::OmniauthCallbacksController
  - Users::OmniauthCallbacksController
  show all

Defined in:
  app/controllers/users/omniauth_callbacks_controller.rb

## Instance Method Summary collapse

- #amazon ⇒ Object
- #failure ⇒ Object
- #github ⇒ Object
- #google_oauth2 ⇒ Object
- #launchpad ⇒ Object

  Workaround for github.com/plataformatec/devise/issues/2432 skip_before_filter :verify_authenticity_token.

- #login_via(provider_name) ⇒ Object
- #stackexchange ⇒ Object

## Instance Method Details

### #amazon ⇒ `Object`

    18
    19
    20
    # File 'app/controllers/users/omniauth_callbacks_controller.rb', line 18

    def amazon
      login_via 'Amazon'
    end

### #failure ⇒ `Object`

    26
    27
    28
    # File 'app/controllers/users/omniauth_callbacks_controller.rb', line 26

    def failure
      redirect_to root_path
    end

### #github ⇒ `Object`

    22
    23
    24
    # File 'app/controllers/users/omniauth_callbacks_controller.rb', line 22

    def github
      login_via 'Github'
    end

### #google_oauth2 ⇒ `Object`

    14
    15
    16
    # File 'app/controllers/users/omniauth_callbacks_controller.rb', line 14

    def google_oauth2
      login_via 'Google'
    end

### #launchpad ⇒ `Object`

Workaround for github.com/plataformatec/devise/issues/2432 skip_before_filter :verify_authenticity_token

    6
    7
    8
    # File 'app/controllers/users/omniauth_callbacks_controller.rb', line 6

    def launchpad
      login_via 'Launchpad'
    end

### #login_via(provider_name) ⇒ `Object`

    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    # File 'app/controllers/users/omniauth_callbacks_controller.rb', line 30

    def login_via(provider_name)
      # TODO: log

      # You need to implement the method below in your model (e.g. app/models/user.rb)
      @user = User.from_omniauth(request.env["omniauth.auth"])

      # Has the user uploaded screenshots while not being logged in?
      # Move the screenshots to the real account and tell the user.
      if @user.persisted?
        flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => provider_name
        sign_in_and_redirect @user, :event => :authentication
      else
        redirect_to new_user_session_url, alert: @user.errors.full_messages.join("\n")
      end
    end

### #stackexchange ⇒ `Object`

    10
    11
    12
    # File 'app/controllers/users/omniauth_callbacks_controller.rb', line 10

    def stackexchange
      login_via 'StackExchange'
    end