Project

General

Profile

maintenance_mode / User.current is always Anonymous

Added by Jan Niggemann (redmine.org team member) almost 12 years ago

Hi all

I'm having an issue with Redmine maintenance (dispatcher already changed:)

module MaintenanceMode
  def self.included(base)
    base.class_eval do
      unloadable
      prepend_before_filter(:show_maintenance_mode_page)

      def show_maintenance_mode_page
        unless User.current.admin?
          render :text => "This site is currently under maintenance. Please check back later." 
          return false
        end
      end
    end
  end
end

# Patches to the Redmine core.

ActionDispatch::Callbacks.to_prepare do
  require_dependency 'application_controller'
  ApplicationController.send(:include, MaintenanceMode)
end

The maintenance text is always displayed, even if I'm authenticated and my user is admin.
I added User.current.lastname as debug output and it's always "Anonymous"...
Any ideas why?


Replies (3)

RE: maintenance_mode / User.current is always Anonymous - Added by Harry Garrood almost 12 years ago

Perhaps this happens before the user is retrieved from the session. Is there an append_before_filter?

RE: maintenance_mode / User.current is always Anonymous - Added by Jan Niggemann (redmine.org team member) almost 12 years ago

OMG, you're right it was the filter chain...
Swapped out prepend_before_filter... with before_filter... and it works.

    (1-3/3)