Sha256: 36e14184f2561073d8b332575f69b4290a150e90b49cdb234df1ce841c46e8bf

Contents?: true

Size: 1.42 KB

Versions: 23

Compression:

Stored size: 1.42 KB

Contents

module Rhoconnect
  module Handler
  	module Authenticate
  	  class Runner
  	  	attr_accessor :app, :route_handler, :params

  	  	include Rhoconnect::Handler::Helpers::Binding

  	  	def initialize(app, route_handler, params = {})
  	  	  raise ArgumentError.new('Invalid app') unless app
  	  	  raise ArgumentError.new('Invalid authenticate handler') unless route_handler
  	  	  @app = app
  	  	  @route_handler = bind_handler(:authenricate_handler_method, route_handler)
  	  	  @params = params
  	  	end

  	  	def run
          if params[:login].nil? or params[:login].empty?
            return false
          end
          user = _do_authenticate
  	  	end

  	  	private
  	  	def _do_authenticate
  	  	  user = nil
  	  	  if params[:login] == 'rhoadmin'
          	user = @route_handler.call
  	  	  else 
  	  	  	if Rhoconnect.appserver
        	    auth_result = Rhoconnect::Model::DynamicAdapterModel.authenticate(params[:login],params[:password])
      	    else
        	    auth_result = @route_handler.call
            end
      	    if auth_result
              params[:login] = auth_result if auth_result.is_a? String
              user = User.load(params[:login]) if User.is_exist?(params[:login])
              if not user
                user = User.create(:login => params[:login])
                app.users << user.id
              end
            end
          end
          user
        end
  	  end
  	end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rhoconnect-7.6.0 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-7.5.1 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-7.4.1 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-7.1.17 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-6.2.0 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-6.0.11 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-5.5.18 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-5.5.17 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-5.5.15 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-5.5.0.22 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-5.5.2 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-5.5.0.7 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-5.5.0.3 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-5.5.0 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-5.1.1 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-4.0.4 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-4.0.3 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-4.0.2 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-4.0.1 lib/rhoconnect/handler/authenticate/runner.rb
rhoconnect-4.0.0 lib/rhoconnect/handler/authenticate/runner.rb