Sha256: 859bd02febfa491d63b1384c49553ac1e2932b8a3955f0ba8d1c9bb49323b53b

Contents?: true

Size: 916 Bytes

Versions: 5

Compression:

Stored size: 916 Bytes

Contents

module InfinumId
  module Users
    class OmniauthCallbacksController < Devise::OmniauthCallbacksController
      def infinum_id
        user = InfinumId::Users::Finder.from_omniauth(omniauth)

        if user
          InfinumId::Users::Updater.call(omniauth['info'], user)
          flash[:notice] = I18n.t 'devise.omniauth_callbacks.success', kind: 'InfinumId'
          sign_in_and_redirect user, event: :authentication
        else
          flash[:notice] = 'You do not have permission to access this application.'
          redirect_to root_path
        end
      end

      def failure
        set_flash_message! :alert, :failure, kind: OmniAuth::Utils.camelize(failed_strategy.name),
                                             reason: failure_message
        redirect_to root_path
      end

      private

      def omniauth
        @omniauth ||= request.env['omniauth.auth']
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
infinum_id-1.3.1 app/controllers/infinum_id/users/omniauth_callbacks_controller.rb
infinum_id-1.3.0 app/controllers/infinum_id/users/omniauth_callbacks_controller.rb
infinum_id-1.2.0 app/controllers/infinum_id/users/omniauth_callbacks_controller.rb
infinum_id-1.1.0 app/controllers/infinum_id/users/omniauth_callbacks_controller.rb
infinum_id-1.0.0 app/controllers/infinum_id/users/omniauth_callbacks_controller.rb