Project

General

Profile

Actions

Defect #18930

closed

session_expiration fails to find active user to set localization for

Added by Josh Miller over 9 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
I18n
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Invalid
Affected version:

Description

Redmine 2.6.1, mysql, amazon linux.

When a session has expired and the user attempts to use Redmine, a 500 error is returned as the session_expiration method is unable to find an active user to set the localization for.

Problem area:

  def session_expiration
    if session[:user_id]
      if session_expired? && !try_to_autologin
        set_localization(User.active.find_by_id(session[:user_id]))
        reset_session
        flash[:error] = l(:error_session_expired)
        redirect_to signin_url
      else
        session[:atime] = Time.now.utc.to_i
      end
    end
  end

With the error:

Started GET "/" for x.x.x.x at 2015-01-21 23:37:33 +0000
Processing by WelcomeController#index as HTML
  User Load (0.7ms) SELECT `users`.* FROM `users` WHERE `users`.`type` IN ('User', 'AnonymousUser') AND `users`.`status` = 1 AND `use
rs`.`id` = 12 LIMIT 1
Completed 500 Internal Server Error in 2.1ms

ArgumentError (wrong number of arguments (1 for 0)):
  app/controllers/application_controller.rb:65:in `session_expiration'

If a reset_session is called before set_localization, and set_localization is without parameters, the correct behavior occurs, where the user is redirected toa login screen and no 500 error occurs.

  def session_expiration
    if session[:user_id]
      if session_expired? && !try_to_autologin
        reset_session
        set_localization
        flash[:error] = l(:error_session_expired)
        redirect_to signin_url
      else
        session[:atime] = Time.now.utc.to_i
      end
    end
  end

Actions

Also available in: Atom PDF