Sha256: 148e3faaf9e304268c7af8f7dd6f6c17f9bb61396888fd35c7f5242e83f63299

Contents?: true

Size: 519 Bytes

Versions: 13

Compression:

Stored size: 519 Bytes

Contents

require 'rhoconnect/middleware/helpers'

module Rhoconnect
  module Middleware
    class LoginRequired
      def initialize(app)
        @app = app
      end

      def call(env)
        begin
          if Rhoconnect.is_login_required(env)
            raise LoginException.new("Not authenticated") if env[Rhoconnect::CURRENT_USER].nil?
          end
          @app.call(env)
        rescue LoginException => le
          return [401, {'Content-Type' => 'text/plain'}, le.message]
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rhoconnect-3.4.5 lib/rhoconnect/middleware/login_required.rb
rhoconnect-3.4.4 lib/rhoconnect/middleware/login_required.rb
rhoconnect-3.4.3 lib/rhoconnect/middleware/login_required.rb
rhoconnect-3.4.2 lib/rhoconnect/middleware/login_required.rb
rhoconnect-3.3.6 lib/rhoconnect/middleware/login_required.rb
rhoconnect-3.3.5 lib/rhoconnect/middleware/login_required.rb
rhoconnect-3.3.4 lib/rhoconnect/middleware/login_required.rb
rhoconnect-3.3.3 lib/rhoconnect/middleware/login_required.rb
rhoconnect-3.3.2 lib/rhoconnect/middleware/login_required.rb
rhoconnect-3.3.1 lib/rhoconnect/middleware/login_required.rb
rhoconnect-3.3.1.beta4 lib/rhoconnect/middleware/login_required.rb
rhoconnect-3.3.1.beta3 lib/rhoconnect/middleware/login_required.rb
rhoconnect-3.3.1.beta2 lib/rhoconnect/middleware/login_required.rb