Skip to content
Snippets Groups Projects
Commit fbf692dd authored by Vladimir Shushlin's avatar Vladimir Shushlin
Browse files

WIP: update pages access control setting on deploy

parent 5cdfbd83
No related merge requests found
......@@ -11,6 +11,8 @@ def initialize(project)
end
def execute
update_access_control_settings_if_needed
if file_equals?(pages_config_file, pages_config_json)
return success(reload: false)
end
......@@ -101,5 +103,22 @@ def read_file(file)
rescue
nil
end
# The default for pages access settings is private,
# but if access control is disabled on the instance level
# pages will be available without access control.
# If access control is then enabled on the isntance level,
# these sites will suddenly become private.
# To avoid this situation we change the project setting to public
# when we deploy pages site
def update_access_control_settings_if_needed
return if Gitlab.config.pages.access_control
# only fix PRIVATE pages sites
return unless project.pages_access_level == ProjectFeature::PRIVATE
new_access_level = project.public? ? ProjectFeature::ENABLED : ProjectFeature::PUBLIC
project.update_column(:pages_access_level, new_access_level)
end
end
end
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment