Sha256: cb26cf6f433f38cba8ef858fc4c5b5a9ca924e7eb9ee8f4715cabc7985102fd9

Contents?: true

Size: 848 Bytes

Versions: 5

Compression:

Stored size: 848 Bytes

Contents

module PhcdevworksAccountsAuth0
  class Auth::HandlerController < ApplicationController

    def callback
      auth_info = request.env['omniauth.auth']
      session[:userinfo] = auth_info['extra']['raw_info']
      redirect_to '/user'
    end

    def failure
      @error_msg = request.params['message']
    end

    def logout
      reset_session
      redirect_to logout_url
    end

    private

    AUTH0_CONFIG = Rails.application.config_for(:auth0)

    def logout_url
      request_params = {
        returnTo: root_url,
        client_id: AUTH0_CONFIG['auth0_client_id']
      }

      URI::HTTPS.build(host: AUTH0_CONFIG['auth0_domain'], path: '/v2/logout', query: to_query(request_params)).to_s
    end

    def to_query(hash)
      hash.map { |k, v| "#{k}=#{CGI.escape(v)}" unless v.nil? }.reject(&:nil?).join('&')
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
phcdevworks_accounts_auth0-0.6.0 app/controllers/phcdevworks_accounts_auth0/auth/handler_controller.rb
phcdevworks_accounts_auth0-0.5.0 app/controllers/phcdevworks_accounts_auth0/auth/handler_controller.rb
phcdevworks_accounts_auth0-0.4.0 app/controllers/phcdevworks_accounts_auth0/auth/handler_controller.rb
phcdevworks_accounts_auth0-0.3.0 app/controllers/phcdevworks_accounts_auth0/auth/handler_controller.rb
phcdevworks_accounts_auth0-0.2.0 app/controllers/phcdevworks_accounts_auth0/auth/handler_controller.rb