Skip to content

Commit

Permalink
Merge pull request #2020 from samvera/add-config-for-devise-options
Browse files Browse the repository at this point in the history
♻️ Add option to override devise configuration
  • Loading branch information
jeremyf authored Oct 10, 2023
2 parents 6a2d624 + 363bc07 commit 014f7b7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
4 changes: 1 addition & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class User < ApplicationRecord
include Blacklight::User
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :invitable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:omniauthable, omniauth_providers: %i[saml openid_connect cas]
devise(*Hyku::Application.user_devise_parameters)

after_create :add_default_group_membership!

Expand Down
15 changes: 15 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ class Application < Rails::Application
# The title to render for the application's HTML > HEAD > TITLE element.
# @return [String]
class_attribute :html_head_title, default: "Hyku", attr_accessor: false

# @!attribute user_devise_parameters
# @return [Object]
#
# This is a value that you want to set in the before_initialize block.
class_attribute :user_devise_parameters, instance_accessor: false, default: [
:database_authenticatable,
:invitable,
:registerable,
:recoverable,
:rememberable,
:trackable,
:validatable,
:omniauthable, { omniauth_providers: %i[saml openid_connect cas] }]

# @!endgroup Class Attributes

# Add this line to load the lib folder first because we need
Expand Down
18 changes: 18 additions & 0 deletions spec/config/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@

RSpec.describe Hyku::Application do
describe '.html_head_title' do
subject { described_class.html_head_title }

it { is_expected.to be_a(String) }
end

describe '.user_devise_parameters' do
subject { described_class.user_devise_parameters }

it do
is_expected.to eq([:database_authenticatable,
:invitable,
:registerable,
:recoverable,
:rememberable,
:trackable,
:validatable,
:omniauthable,
{ omniauth_providers: %i[saml openid_connect cas] }])
end
end
end

0 comments on commit 014f7b7

Please sign in to comment.