From c25e338ac4fa148735c1a3b141efe40f2d0e47ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20Bo=CC=88ning?= Date: Fri, 16 Apr 2021 20:48:32 +0100 Subject: [PATCH] Allow setting a layout for user_sessions and passwords controller A layout can be set using an initializer in the host app. ``` Alchemy::Devise.layout = "login" ``` The fallback value ensures backwards compatibility. --- app/controllers/alchemy/admin/passwords_controller.rb | 2 +- app/controllers/alchemy/admin/user_sessions_controller.rb | 2 +- lib/alchemy/devise.rb | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controllers/alchemy/admin/passwords_controller.rb b/app/controllers/alchemy/admin/passwords_controller.rb index df569e8..c5ecd89 100644 --- a/app/controllers/alchemy/admin/passwords_controller.rb +++ b/app/controllers/alchemy/admin/passwords_controller.rb @@ -13,7 +13,7 @@ class PasswordsController < ::Devise::PasswordsController helper "Alchemy::Admin::Base" - layout "alchemy/admin" + layout Alchemy::Devise.layout private diff --git a/app/controllers/alchemy/admin/user_sessions_controller.rb b/app/controllers/alchemy/admin/user_sessions_controller.rb index 2cb9337..4fe8e95 100644 --- a/app/controllers/alchemy/admin/user_sessions_controller.rb +++ b/app/controllers/alchemy/admin/user_sessions_controller.rb @@ -18,7 +18,7 @@ class UserSessionsController < ::Devise::SessionsController helper "Alchemy::Admin::Base" - layout "alchemy/admin" + layout Alchemy::Devise.layout def create authenticate_user! diff --git a/lib/alchemy/devise.rb b/lib/alchemy/devise.rb index 65eb8a2..1caae84 100644 --- a/lib/alchemy/devise.rb +++ b/lib/alchemy/devise.rb @@ -37,5 +37,12 @@ def self.devise_modules end module Devise + def self.layout=(value) + @layout = value + end + + def self.layout + @layout || "alchemy/admin" + end end end