summaryrefslogtreecommitdiff
path: root/app/controllers/admin
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/admin')
-rw-r--r--app/controllers/admin/application_settings_controller.rb11
-rw-r--r--app/controllers/admin/dashboard_controller.rb5
-rw-r--r--app/controllers/admin/sessions_controller.rb33
-rw-r--r--app/controllers/admin/users_controller.rb16
4 files changed, 62 insertions, 3 deletions
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb
index fbf63997b15..f7e33c09928 100644
--- a/app/controllers/admin/application_settings_controller.rb
+++ b/app/controllers/admin/application_settings_controller.rb
@@ -6,9 +6,9 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
before_action :set_application_setting
before_action :whitelist_query_limiting, only: [:usage_data]
- VALID_SETTING_PANELS = %w(general integrations repository templates
+ VALID_SETTING_PANELS = %w(general integrations repository
ci_cd reporting metrics_and_profiling
- network geo preferences).freeze
+ network preferences).freeze
VALID_SETTING_PANELS.each do |action|
define_method(action) { perform_update if submitted? }
@@ -145,10 +145,15 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
end
def render_update_error
- action = VALID_SETTING_PANELS.include?(action_name) ? action_name : :general
+ action = valid_setting_panels.include?(action_name) ? action_name : :general
render action
end
+
+ # overridden in EE
+ def valid_setting_panels
+ VALID_SETTING_PANELS
+ end
end
Admin::ApplicationSettingsController.prepend_if_ee('EE::Admin::ApplicationSettingsController')
diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb
index c36bbaab23b..f24ce9b5d03 100644
--- a/app/controllers/admin/dashboard_controller.rb
+++ b/app/controllers/admin/dashboard_controller.rb
@@ -2,6 +2,7 @@
class Admin::DashboardController < Admin::ApplicationController
include CountHelper
+ helper_method :show_license_breakdown?
COUNTED_ITEMS = [Project, User, Group].freeze
@@ -13,6 +14,10 @@ class Admin::DashboardController < Admin::ApplicationController
@groups = Group.order_id_desc.with_route.limit(10)
end
# rubocop: enable CodeReuse/ActiveRecord
+
+ def show_license_breakdown?
+ false
+ end
end
Admin::DashboardController.prepend_if_ee('EE::Admin::DashboardController')
diff --git a/app/controllers/admin/sessions_controller.rb b/app/controllers/admin/sessions_controller.rb
new file mode 100644
index 00000000000..1f946e41995
--- /dev/null
+++ b/app/controllers/admin/sessions_controller.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+class Admin::SessionsController < ApplicationController
+ include InternalRedirect
+
+ before_action :user_is_admin!
+
+ def new
+ # Renders a form in which the admin can enter their password
+ end
+
+ def create
+ if current_user_mode.enable_admin_mode!(password: params[:password])
+ redirect_location = stored_location_for(:redirect) || admin_root_path
+ redirect_to safe_redirect_path(redirect_location)
+ else
+ flash.now[:alert] = _('Invalid Login or password')
+ render :new
+ end
+ end
+
+ def destroy
+ current_user_mode.disable_admin_mode!
+
+ redirect_to root_path, status: :found, notice: _('Admin mode disabled')
+ end
+
+ private
+
+ def user_is_admin!
+ render_404 unless current_user&.admin?
+ end
+end
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index 61d36d1efc2..4c1ac8f206a 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -58,6 +58,22 @@ class Admin::UsersController < Admin::ApplicationController
end
end
+ def activate
+ return redirect_back_or_admin_user(notice: _("Error occurred. A blocked user must be unblocked to be activated")) if user.blocked?
+
+ user.activate
+ redirect_back_or_admin_user(notice: _("Successfully activated"))
+ end
+
+ def deactivate
+ return redirect_back_or_admin_user(notice: _("Error occurred. A blocked user cannot be deactivated")) if user.blocked?
+ return redirect_back_or_admin_user(notice: _("Successfully deactivated")) if user.deactivated?
+ return redirect_back_or_admin_user(notice: _("The user you are trying to deactivate has been active in the past %{minimum_inactive_days} days and cannot be deactivated") % { minimum_inactive_days: ::User::MINIMUM_INACTIVE_DAYS }) unless user.can_be_deactivated?
+
+ user.deactivate
+ redirect_back_or_admin_user(notice: _("Successfully deactivated"))
+ end
+
def block
if update_user { |user| user.block }
redirect_back_or_admin_user(notice: _("Successfully blocked"))