Commit 826adaaf authored by Robert Speicher's avatar Robert Speicher

Merge branch 'refactor-admin-controllers-params' into 'master'

Refactor admin controllers params

See merge request !8521
parents 34087fe3 d8d9d0c7
...@@ -67,69 +67,76 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController ...@@ -67,69 +67,76 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
params.delete(:domain_blacklist_raw) if params[:domain_blacklist_file] params.delete(:domain_blacklist_raw) if params[:domain_blacklist_file]
params.require(:application_setting).permit( params.require(:application_setting).permit(
:default_projects_limit, application_setting_params_ce
:default_branch_protection, )
:signup_enabled, end
:signin_enabled,
:require_two_factor_authentication, def application_setting_params_ce
:two_factor_grace_period, [
:gravatar_enabled, :admin_notification_email,
:sign_in_text,
:after_sign_up_text,
:help_page_text,
:home_page_url,
:after_sign_out_path, :after_sign_out_path,
:max_attachment_size, :after_sign_up_text,
:session_expire_delay, :akismet_api_key,
:akismet_enabled,
:container_registry_token_expire_delay,
:default_branch_protection,
:default_group_visibility,
:default_project_visibility, :default_project_visibility,
:default_projects_limit,
:default_snippet_visibility, :default_snippet_visibility,
:default_group_visibility,
:domain_whitelist_raw,
:domain_blacklist_enabled, :domain_blacklist_enabled,
:domain_blacklist_raw,
:domain_blacklist_file, :domain_blacklist_file,
:version_check_enabled, :domain_blacklist_raw,
:admin_notification_email, :domain_whitelist_raw,
:user_oauth_applications, :email_author_in_body,
:user_default_external, :enabled_git_access_protocol,
:shared_runners_enabled, :gravatar_enabled,
:shared_runners_text, :help_page_text,
:home_page_url,
:housekeeping_bitmaps_enabled,
:housekeeping_enabled,
:housekeeping_full_repack_period,
:housekeeping_gc_period,
:housekeeping_incremental_repack_period,
:html_emails_enabled,
:koding_enabled,
:koding_url,
:max_artifacts_size, :max_artifacts_size,
:max_attachment_size,
:metrics_enabled, :metrics_enabled,
:metrics_host, :metrics_host,
:metrics_port,
:metrics_pool_size,
:metrics_timeout,
:metrics_method_call_threshold, :metrics_method_call_threshold,
:metrics_packet_size,
:metrics_pool_size,
:metrics_port,
:metrics_sample_interval, :metrics_sample_interval,
:metrics_timeout,
:recaptcha_enabled, :recaptcha_enabled,
:recaptcha_site_key,
:recaptcha_private_key, :recaptcha_private_key,
:sentry_enabled, :recaptcha_site_key,
:sentry_dsn,
:akismet_enabled,
:akismet_api_key,
:koding_enabled,
:koding_url,
:email_author_in_body,
:html_emails_enabled,
:repository_checks_enabled, :repository_checks_enabled,
:metrics_packet_size, :require_two_factor_authentication,
:session_expire_delay,
:sign_in_text,
:signin_enabled,
:signup_enabled,
:sentry_dsn,
:sentry_enabled,
:send_user_confirmation_email, :send_user_confirmation_email,
:container_registry_token_expire_delay, :shared_runners_enabled,
:enabled_git_access_protocol, :shared_runners_text,
:sidekiq_throttling_enabled, :sidekiq_throttling_enabled,
:sidekiq_throttling_factor, :sidekiq_throttling_factor,
:housekeeping_enabled, :two_factor_grace_period,
:housekeeping_bitmaps_enabled, :user_default_external,
:housekeeping_incremental_repack_period, :user_oauth_applications,
:housekeeping_full_repack_period, :version_check_enabled,
:housekeeping_gc_period,
disabled_oauth_sign_in_sources: [],
import_sources: [],
repository_storages: [], repository_storages: [],
restricted_visibility_levels: [], restricted_visibility_levels: [],
import_sources: [],
disabled_oauth_sign_in_sources: [],
sidekiq_throttling_queues: [] sidekiq_throttling_queues: []
) ]
end end
end end
...@@ -61,7 +61,11 @@ class Admin::GroupsController < Admin::ApplicationController ...@@ -61,7 +61,11 @@ class Admin::GroupsController < Admin::ApplicationController
end end
def group_params def group_params
params.require(:group).permit( params.require(:group).permit(group_params_ce)
end
def group_params_ce
[
:avatar, :avatar,
:description, :description,
:lfs_enabled, :lfs_enabled,
...@@ -69,6 +73,6 @@ class Admin::GroupsController < Admin::ApplicationController ...@@ -69,6 +73,6 @@ class Admin::GroupsController < Admin::ApplicationController
:path, :path,
:request_access_enabled, :request_access_enabled,
:visibility_level :visibility_level
) ]
end end
end end
...@@ -161,15 +161,6 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -161,15 +161,6 @@ class Admin::UsersController < Admin::ApplicationController
@user ||= User.find_by!(username: params[:id]) @user ||= User.find_by!(username: params[:id])
end end
def user_params
params.require(:user).permit(
:email, :remember_me, :bio, :name, :username,
:skype, :linkedin, :twitter, :website_url, :color_scheme_id, :theme_id, :force_random_password,
:extern_uid, :provider, :password_expires_at, :avatar, :hide_no_ssh_key, :hide_no_password,
:projects_limit, :can_create_group, :admin, :key_id, :external
)
end
def redirect_back_or_admin_user(options = {}) def redirect_back_or_admin_user(options = {})
redirect_back_or_default(default: default_route, options: options) redirect_back_or_default(default: default_route, options: options)
end end
...@@ -177,4 +168,36 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -177,4 +168,36 @@ class Admin::UsersController < Admin::ApplicationController
def default_route def default_route
[:admin, @user] [:admin, @user]
end end
def user_params
params.require(:user).permit(user_params_ce)
end
def user_params_ce
[
:admin,
:avatar,
:bio,
:can_create_group,
:color_scheme_id,
:email,
:extern_uid,
:external,
:force_random_password,
:hide_no_password,
:hide_no_ssh_key,
:key_id,
:linkedin,
:name,
:password_expires_at,
:projects_limit,
:provider,
:remember_me,
:skype,
:theme_id,
:twitter,
:username,
:website_url
]
end
end end
Markdown is supported
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