Skip to content

Commit

Permalink
Allow setting a layout for user_sessions and passwords controller
Browse files Browse the repository at this point in the history
A layout can be set using an initializer in the host app.

```
Alchemy::Devise.layout = "login"
```

The fallback value ensures backwards compatibility.
  • Loading branch information
robinboening committed Apr 18, 2021
1 parent 0c7279d commit c25e338
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/alchemy/admin/passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PasswordsController < ::Devise::PasswordsController

helper "Alchemy::Admin::Base"

layout "alchemy/admin"
layout Alchemy::Devise.layout

private

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/alchemy/admin/user_sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class UserSessionsController < ::Devise::SessionsController

helper "Alchemy::Admin::Base"

layout "alchemy/admin"
layout Alchemy::Devise.layout

def create
authenticate_user!
Expand Down
7 changes: 7 additions & 0 deletions lib/alchemy/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c25e338

Please sign in to comment.