Class: ForemanTasks::Dynflow::ConsoleAuthorizer

Inherits:
Object
  • Object
show all
Defined in:
lib/foreman_tasks/dynflow/console_authorizer.rb

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ ConsoleAuthorizer

Returns a new instance of ConsoleAuthorizer.



4
5
6
7
8
9
# File 'lib/foreman_tasks/dynflow/console_authorizer.rb', line 4

def initialize(env)
  @rack_request = Rack::Request.new(env)
  @user_id = @rack_request.session[:user]
  @expires_at = @rack_request.session[:expires_at]
  @user = User.where(:id => @user_id).first unless session_expired?
end

Instance Method Details

#allow?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/foreman_tasks/dynflow/console_authorizer.rb', line 11

def allow?
  @user && (unlimited_edit? || authorized_for_task?)
end