mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
Move authentication settings tabs as separate page to new menu node
This commit is contained in:
@@ -30,6 +30,8 @@
|
||||
class AuthenticationController < ApplicationController
|
||||
before_action :disable_api
|
||||
before_action :require_login
|
||||
layout 'admin'
|
||||
menu_item :authentication_settings
|
||||
|
||||
accept_key_auth :index
|
||||
|
||||
@@ -38,4 +40,18 @@ class AuthenticationController < ApplicationController
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
if params[:settings]
|
||||
Settings::UpdateService
|
||||
.new(user: current_user)
|
||||
.call(settings: permitted_params.settings.to_h)
|
||||
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
end
|
||||
end
|
||||
|
||||
def authentication_settings
|
||||
render 'authentication_settings'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -41,17 +41,9 @@ class SettingsController < ApplicationController
|
||||
def edit
|
||||
@notifiables = Redmine::Notifiable.all
|
||||
if request.post? && params[:settings]
|
||||
permitted_params.settings.to_h.each do |name, value|
|
||||
if value.is_a?(Array)
|
||||
# remove blank values in array settings
|
||||
value.delete_if(&:blank?)
|
||||
elsif value.is_a?(Hash)
|
||||
value.delete_if { |_, v| v.blank? }
|
||||
else
|
||||
value = value.strip
|
||||
end
|
||||
Setting[name] = value
|
||||
end
|
||||
Settings::UpdateService
|
||||
.new(user: current_user)
|
||||
.call(settings: permitted_params.settings.to_h)
|
||||
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
redirect_to action: 'edit', tab: params[:tab]
|
||||
|
||||
@@ -36,7 +36,6 @@ module SettingsHelper
|
||||
[
|
||||
{ name: 'general', partial: 'settings/general', label: :label_general },
|
||||
{ name: 'display', partial: 'settings/display', label: :label_display },
|
||||
{ name: 'authentication', partial: 'settings/authentication', label: :label_authentication },
|
||||
{ name: 'users', partial: 'settings/users', label: :label_user_plural },
|
||||
{ name: 'projects', partial: 'settings/projects', label: :label_project_plural },
|
||||
{ name: 'work_packages', partial: 'settings/work_packages', label: :label_work_package_tracking },
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#-- encoding: UTF-8
|
||||
|
||||
#-- copyright
|
||||
# OpenProject is a project management system.
|
||||
# Copyright (C) 2012-2019 the OpenProject Foundation (OPF)
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License version 3.
|
||||
#
|
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2010-2013 the ChiliProject Team
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# See doc/COPYRIGHT.rdoc for more details.
|
||||
#++
|
||||
|
||||
class Settings::UpdateService < ::BaseServices::Update
|
||||
attr_accessor :user
|
||||
|
||||
def initialize(user)
|
||||
self.user = user
|
||||
end
|
||||
|
||||
def call(settings:, &block)
|
||||
settings.each do |name, value|
|
||||
if value.is_a?(Array)
|
||||
# remove blank values in array settings
|
||||
value.delete_if(&:blank?)
|
||||
elsif value.is_a?(Hash)
|
||||
value.delete_if { |_, v| v.blank? }
|
||||
else
|
||||
value = value.strip
|
||||
end
|
||||
Setting[name] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
+3
-1
@@ -26,9 +26,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
See docs/COPYRIGHT.rdoc for more details.
|
||||
|
||||
++#%>
|
||||
<% html_title l(:label_administration), l(:label_authentication) -%>
|
||||
|
||||
<%= styled_form_tag({ action: 'edit', tab: 'authentication' }) do %>
|
||||
<%= toolbar title: l(:label_authentication) %>
|
||||
|
||||
<%= styled_form_tag({ action: :edit }) do %>
|
||||
<section class="form--section">
|
||||
<fieldset class="form--fieldset">
|
||||
<legend class="form--fieldset-legend"><%= I18n.t(:general, scope: [:settings]) %></legend>
|
||||
@@ -183,10 +183,15 @@ Redmine::MenuManager.map :admin_menu do |menu|
|
||||
icon: 'icon2 icon-settings2'
|
||||
|
||||
menu.push :authentication,
|
||||
{ controller: '/oauth/applications', action: 'index' },
|
||||
{ controller: '/authentication', action: 'authentication_settings' },
|
||||
caption: :label_authentication,
|
||||
icon: 'icon2 icon-two-factor-authentication'
|
||||
|
||||
menu.push :authentication_settings,
|
||||
{ controller: '/authentication', action: 'authentication_settings' },
|
||||
caption: :label_settings,
|
||||
parent: :authentication
|
||||
|
||||
menu.push :ldap_authentication,
|
||||
{ controller: '/ldap_auth_sources', action: 'index' },
|
||||
parent: :authentication,
|
||||
|
||||
+6
-1
@@ -539,7 +539,12 @@ OpenProject::Application.routes.draw do
|
||||
patch 'user_settings', action: 'user_settings'
|
||||
end
|
||||
|
||||
get 'authentication' => 'authentication#index'
|
||||
|
||||
scope controller: 'authentication' do
|
||||
get 'authentication' => 'authentication#index'
|
||||
get 'authentication_settings' => 'authentication#authentication_settings'
|
||||
post 'authentication_settings' => 'authentication#edit'
|
||||
end
|
||||
|
||||
resources :colors do
|
||||
member do
|
||||
|
||||
Reference in New Issue
Block a user