about summary refs log tree commit diff
path: root/app/controllers/settings
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/settings')
-rw-r--r--app/controllers/settings/base_controller.rb5
-rw-r--r--app/controllers/settings/flavours_controller.rb28
-rw-r--r--app/controllers/settings/login_activities_controller.rb6
-rw-r--r--app/controllers/settings/two_factor_authentication/webauthn_credentials_controller.rb4
4 files changed, 43 insertions, 0 deletions
diff --git a/app/controllers/settings/base_controller.rb b/app/controllers/settings/base_controller.rb
index 8722fd64a..bf17b918c 100644
--- a/app/controllers/settings/base_controller.rb
+++ b/app/controllers/settings/base_controller.rb
@@ -1,6 +1,7 @@
 # frozen_string_literal: true
 
 class Settings::BaseController < ApplicationController
+  before_action :set_pack
   layout 'admin'
 
   before_action :authenticate_user!
@@ -9,6 +10,10 @@ class Settings::BaseController < ApplicationController
 
   private
 
+  def set_pack
+    use_pack 'settings'
+  end
+
   def set_body_classes
     @body_classes = 'admin'
   end
diff --git a/app/controllers/settings/flavours_controller.rb b/app/controllers/settings/flavours_controller.rb
new file mode 100644
index 000000000..c1172598b
--- /dev/null
+++ b/app/controllers/settings/flavours_controller.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class Settings::FlavoursController < Settings::BaseController
+  layout 'admin'
+
+  before_action :authenticate_user!
+
+  skip_before_action :require_functional!
+
+  def index
+    redirect_to action: 'show', flavour: current_flavour
+  end
+
+  def show
+    unless Themes.instance.flavours.include?(params[:flavour]) || (params[:flavour] == current_flavour)
+      redirect_to action: 'show', flavour: current_flavour
+    end
+
+    @listing = Themes.instance.flavours
+    @selected = params[:flavour]
+  end
+
+  def update
+    current_user.settings.update(flavour: params.require(:flavour), skin: params.dig(:user, :setting_skin))
+    current_user.save
+    redirect_to action: 'show', flavour: params[:flavour]
+  end
+end
diff --git a/app/controllers/settings/login_activities_controller.rb b/app/controllers/settings/login_activities_controller.rb
index 57fa6aef0..ee77524b1 100644
--- a/app/controllers/settings/login_activities_controller.rb
+++ b/app/controllers/settings/login_activities_controller.rb
@@ -4,4 +4,10 @@ class Settings::LoginActivitiesController < Settings::BaseController
   def index
     @login_activities = LoginActivity.where(user: current_user).order(id: :desc).page(params[:page])
   end
+
+  private
+
+  def set_pack
+    use_pack 'settings'
+  end
 end
diff --git a/app/controllers/settings/two_factor_authentication/webauthn_credentials_controller.rb b/app/controllers/settings/two_factor_authentication/webauthn_credentials_controller.rb
index d1ee7dc19..5a9029a42 100644
--- a/app/controllers/settings/two_factor_authentication/webauthn_credentials_controller.rb
+++ b/app/controllers/settings/two_factor_authentication/webauthn_credentials_controller.rb
@@ -85,6 +85,10 @@ module Settings
 
       private
 
+      def set_pack
+        use_pack 'auth'
+      end
+
       def require_otp_enabled
         unless current_user.otp_enabled?
           flash[:error] = t('webauthn_credentials.otp_required')