Sha256: 306c3cc8496979e6d13d4ac09a179bbb1a5fa0cf7b07896d12b018d05bccf405

Contents?: true

Size: 669 Bytes

Versions: 40

Compression:

Stored size: 669 Bytes

Contents

module Shipit
  class GithubAuthenticationController < ActionController::Base
    include Shipit::Engine.routes.url_helpers

    def callback
      return_url = request.env['omniauth.origin'] || root_path
      auth = request.env['omniauth.auth']

      return render 'failed', layout: false if auth.blank?

      session[:user_id] = sign_in_github(auth)

      redirect_to return_url
    end

    def logout
      reset_session
      redirect_to root_path
    end

    private

    def sign_in_github(auth)
      user = User.find_or_create_from_github(auth.extra.raw_info)
      user.update(github_access_token: auth.credentials.token)
      user.id
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
shipit-engine-0.31.0 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.30.0 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.29.0 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.28.1 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.28.0 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.27.1 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.27.0 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.26.0 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.25.1 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.25.0 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.24.0 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.23.1 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.23.0 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.22.0 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.21.0 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.20.1 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.20.0 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.19.0 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.18.1 app/controllers/shipit/github_authentication_controller.rb
shipit-engine-0.18.0 app/controllers/shipit/github_authentication_controller.rb