d13669716a
In GitLab EE, a GitLab instance can be read-only (e.g. when it's a Geo secondary node). But in GitLab CE it also might be useful to have the "read-only" idea around. So port it back to GitLab CE. Also having the principle of read-only in GitLab CE would hopefully lead to less errors introduced, doing write operations when there aren't allowed for read-only calls. Closes gitlab-org/gitlab-ce#37534.
25 lines
618 B
Ruby
25 lines
618 B
Ruby
# Provides a base class for Admin controllers to subclass
|
|
#
|
|
# Automatically sets the layout and ensures an administrator is logged in
|
|
class Admin::ApplicationController < ApplicationController
|
|
before_action :authenticate_admin!
|
|
before_action :display_read_only_information
|
|
layout 'admin'
|
|
|
|
def authenticate_admin!
|
|
render_404 unless current_user.admin?
|
|
end
|
|
|
|
def display_read_only_information
|
|
return unless Gitlab::Database.read_only?
|
|
|
|
flash.now[:notice] = read_only_message
|
|
end
|
|
|
|
private
|
|
|
|
# Overridden in EE
|
|
def read_only_message
|
|
_('You are on a read-only GitLab instance.')
|
|
end
|
|
end
|