Sha256: 7dd1546e01cbe684ca9170fa256961a4042aaa848acd53d7139acbddc9b4295e

Contents?: true

Size: 946 Bytes

Versions: 10

Compression:

Stored size: 946 Bytes

Contents

# frozen_string_literal: true

require_dependency 'stenographer/application_controller'

module Stenographer
  class AuthenticationsController < ApplicationController
    skip_before_action :verify_authenticity_token

    def create
      auth_hash = request.env['omniauth.auth']
      @hash = auth_hash

      if auth_hash.try(:provider).present?
        Authentication.find_or_create_by(provider: auth_hash.provider) do |authentication|
          authentication.uid = auth_hash.uid
          authentication.credentials = auth_hash.credentials.present? ? auth_hash.credentials.to_json : nil
          authentication.source = auth_hash.to_json
        end

        flash[:notice] = 'Successfully created the Authentication'
        redirect_to admin_authentications_path
      else
        flash[:alert] = 'Did not receive oAuth provider info'
        redirect_back(fallback_location: root_path)
      end
    end

    def failure; end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
stenographer-rails-0.7.4 app/controllers/stenographer/authentications_controller.rb
stenographer-rails-0.7.3 app/controllers/stenographer/authentications_controller.rb
stenographer-rails-0.7.1 app/controllers/stenographer/authentications_controller.rb
stenographer-rails-0.7.0 app/controllers/stenographer/authentications_controller.rb
stenographer-rails-0.6.5 app/controllers/stenographer/authentications_controller.rb
stenographer-rails-0.6.4 app/controllers/stenographer/authentications_controller.rb
stenographer-rails-0.6.3 app/controllers/stenographer/authentications_controller.rb
stenographer-rails-0.6.2 app/controllers/stenographer/authentications_controller.rb
stenographer-rails-0.6.1 app/controllers/stenographer/authentications_controller.rb
stenographer-rails-0.6.0 app/controllers/stenographer/authentications_controller.rb