Skip to content

Commit

Permalink
♻️ Add option to override devise configuration
Browse files Browse the repository at this point in the history
For Adventist, we wanted to disable registration of accounts as this was
creating a case where folks were creating their own accounts and
tenants.

Related to:

- https://github.com/scientist-softserv/adventist-dl/issues/492
- https://github.com/scientist-softserv/adventist-dl/issues/618
- #1964
- scientist-softserv/adventist-dl#493
  • Loading branch information
jeremyf committed Oct 10, 2023
1 parent 6a2d624 commit b2874f5
Show file tree
Hide file tree
Showing 3 changed files with 32 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
16 changes: 16 additions & 0 deletions spec/config/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@

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 { is_expected.to eq([
:database_authenticatable,
:invitable,
:registerable,
:recoverable,
:rememberable,
:trackable,
:validatable,
:omniauthable, { omniauth_providers: %i[saml openid_connect cas] }]) }
end
end

0 comments on commit b2874f5

Please sign in to comment.