Sha256: fd410e1295f83a03316f38bbf0f5c85cffe8d703318ae254e424b2f7b6d13410

Contents?: true

Size: 634 Bytes

Versions: 9

Compression:

Stored size: 634 Bytes

Contents

require 'uri'

module Capcoauth
  class LoginController < Capcoauth::ApplicationController
    def show

      # If set in session
      if session[:capcoauth_access_token]

        # Attempt to verify
        begin
          capcoauth_token.verify
          redirect_to session.delete(:previous_url) || root_url, notice: 'You are already logged in'
          return
        rescue; end
      end

      # Otherwise, redirect
      redirect_to "#{Capcoauth.configuration.capcoauth_url}/oauth/authorize?client_id=#{Capcoauth.configuration.client_id}&redirect_uri=#{URI.encode(oauth_callback_url)}&response_type=code"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
capcoauth-0.4.0 app/controllers/capcoauth/login_controller.rb
capcoauth-0.3.3 app/controllers/capcoauth/login_controller.rb
capcoauth-0.3.2 app/controllers/capcoauth/login_controller.rb
capcoauth-0.3.1 app/controllers/capcoauth/login_controller.rb
capcoauth-0.3.0 app/controllers/capcoauth/login_controller.rb
capcoauth-0.2.3 app/controllers/capcoauth/login_controller.rb
capcoauth-0.2.2 app/controllers/capcoauth/login_controller.rb
capcoauth-0.2.1 app/controllers/capcoauth/login_controller.rb
capcoauth-0.2.0 app/controllers/capcoauth/login_controller.rb