Skip to content

Commit

Permalink
Merge pull request theforeman#159 from ShimShtein/12966
Browse files Browse the repository at this point in the history
Fixes #12966 - get rid if values_at in console authorizer
  • Loading branch information
iNecas committed Jan 7, 2016
2 parents 08256a2 + afc10f8 commit 3b6f992
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/foreman_tasks/dynflow/console_authorizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
module ForemanTasks
class Dynflow::ConsoleAuthorizer
def initialize(env)
@rack_request = Rack::Request.new(env)
@user_id, @expires_at = @rack_request.session.values_at('user', 'expires_at')
@user = User.where(:id => @user_id).first unless session_expired?
@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

def allow?
Expand Down
2 changes: 1 addition & 1 deletion test/unit/dynflow_console_authorizer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def dynflow_console_authorized?(task = nil)
dynflow_path = '/'
dynflow_path += task.external_id.to_s if task
dynflow_rack_env = { "rack.session" => { "user" => user.id, "expires_at" => Time.now + 100 },
"PATH_INFO" => dynflow_path}
"PATH_INFO" => dynflow_path}.with_indifferent_access
ForemanTasks::Dynflow::ConsoleAuthorizer.new(dynflow_rack_env).allow?
end

Expand Down

0 comments on commit 3b6f992

Please sign in to comment.