sun-sword 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -10
  3. data/lib/generators/sun_sword/frontend_generator.rb +43 -19
  4. data/lib/generators/sun_sword/init_generator.rb +15 -0
  5. data/lib/generators/sun_sword/scaffold_generator.rb +135 -9
  6. data/lib/generators/sun_sword/templates_frontend/config/devise.rb +313 -0
  7. data/lib/generators/sun_sword/templates_frontend/controllers/application_controller.rb.tt +7 -3
  8. data/lib/generators/sun_sword/templates_frontend/controllers/site_controller.rb +1 -0
  9. data/lib/generators/sun_sword/templates_frontend/db/migrate/20241117042039_devise_create_auths.rb +47 -0
  10. data/lib/generators/sun_sword/templates_frontend/db/migrate/20241117043154_create_models_accounts.rb +11 -0
  11. data/lib/generators/sun_sword/templates_frontend/db/migrate/20241117044142_create_models_users.rb +16 -0
  12. data/lib/generators/sun_sword/templates_frontend/db/seeds.rb +3 -0
  13. data/lib/generators/sun_sword/templates_frontend/db/structures/example.yaml.tt +106 -0
  14. data/lib/generators/sun_sword/templates_frontend/frontend/pages/web.js +2 -8
  15. data/lib/generators/sun_sword/templates_frontend/models/models/account.rb +4 -0
  16. data/lib/generators/sun_sword/templates_frontend/models/models/auth.rb +8 -0
  17. data/lib/generators/sun_sword/templates_frontend/models/models/user.rb +5 -0
  18. data/lib/generators/sun_sword/templates_frontend/views/layouts/dashboard/_sidebar.html.erb.tt +11 -1
  19. data/lib/generators/sun_sword/templates_frontend/views/layouts/dashboard/application.html.erb.tt +6 -9
  20. data/lib/generators/sun_sword/templates_init/config/initializers/sun_sword.rb +3 -0
  21. data/lib/generators/sun_sword/templates_scaffold/controllers/controller.rb.tt +22 -18
  22. data/lib/generators/sun_sword/templates_scaffold/views/_form.html.erb.tt +3 -8
  23. data/lib/generators/sun_sword/templates_scaffold/views/components/menu/link.html.erb.tt +1 -1
  24. data/lib/generators/sun_sword/templates_scaffold/views/index.html.erb.tt +4 -4
  25. data/lib/generators/sun_sword/templates_scaffold/views/show.html.erb.tt +2 -2
  26. data/lib/sun-sword.rb +4 -2
  27. data/lib/sun_sword/configuration.rb +29 -0
  28. data/lib/sun_sword/version.rb +1 -1
  29. metadata +14 -3
  30. data/lib/generators/sun_sword/templates_frontend/controllers/dashboard/site_controller.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c8b5bbb0e89debafcd22667bbce169c0fb847525e117a171f4de9132164ebad
4
- data.tar.gz: 8b6201d7d4b9fe8f7bebd6237d81b66ed8a83c2dab005174c1763296ffd95961
3
+ metadata.gz: cb494f2a53c1b516860199cb7c8c692f77c8a064d8ed79454a4baa2720781fdf
4
+ data.tar.gz: 159150643bb604b46e20ebe2c7673955a3506590f108dea95785cbfaf1ae583a
5
5
  SHA512:
6
- metadata.gz: a87faefb890fcd7c4d99796079f914e441616c1945078b302d12492321c2b9859556b13ca79364cd3cb05f92f3c80b493c241172377ac341f949632833daafaf
7
- data.tar.gz: 3876268e5930319b5204f7351c15ffaee81b7cfca94a3bcac893de864f1ed6a2cf96be7b30a1e902e44b29907e94d975ab720b7b2353d280456a7ef007f9ab5e
6
+ metadata.gz: 8fc13564eb994ffd6c09caf9d1e585c333244be340e31eb4cef1abeeee26a079a6889f5854b510e3412bf5e804c5c1809b4eac44096b57e9869ce052a75a7a28
7
+ data.tar.gz: 84d65e98117489c21b4490957a36d6f54f62abbfcf0400cdd5c3410e5c949f1c90934fc1f4910d69c525dcdc90a7597592aff7873a0efc100fbc84974f33787c
data/README.md CHANGED
@@ -10,19 +10,19 @@ Add this line to your application's Gemfile:
10
10
  ```ruby
11
11
  gem 'rider-kick'
12
12
  gem 'sun-sword'
13
-
14
13
  ```
15
14
 
16
- And then execute:
17
- $ rails new kotaro_minami -d=postgresql -T --skip-javascript --skip-asset-pipeline
18
- $ bundle install
19
- $ rails generate rider_kick:init
20
- $ rails generate rider_kick:clean_arch --setup
21
- $ rails db:drop db:create db:migrate db:seed
22
- $ rails generate sun_sword:frontend
23
-
24
- $ rubocop -a
25
15
 
16
+ And then execute:
17
+ ```bash
18
+ $ rails new kotaro_minami -d=postgresql -T --skip-javascript --skip-asset-pipeline
19
+ $ bundle install
20
+ $ rails generate rider_kick:init
21
+ $ rails generate rider_kick:clean_arch --setup
22
+ $ rails db:drop db:create db:migrate db:seed
23
+ $ rails generate sun_sword:frontend
24
+ $ rubocop -a
25
+ ```
26
26
  ## Usage
27
27
  ```bash
28
28
  Description:
@@ -13,12 +13,10 @@ module SunSword
13
13
  desc 'This generator installs Vite with Rails 7 configuration'
14
14
 
15
15
  def setup
16
+ validation!
16
17
  remove_assets_folder
17
18
  copy_assets_from_template
18
19
 
19
- # copy_database_config
20
- # copy_env_development
21
-
22
20
  add_vite_to_gemfile
23
21
  install_vite
24
22
  configure_vite
@@ -28,10 +26,50 @@ module SunSword
28
26
  generate_controllers_site
29
27
  generate_components
30
28
  modify_layout_for_vite
29
+
30
+ setup_migration
31
+ setup_models
32
+ gem_dependencies
31
33
  end
32
34
 
33
35
  private
34
36
 
37
+ def gem_dependencies
38
+ # auth
39
+ # rails generate devise:install
40
+ # config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
41
+ # devise_for :auths, class_name: "Models::Auth", controllers: {
42
+ # sessions: 'auths/sessions'
43
+ # }
44
+ gem 'devise', '~> 4.9'
45
+
46
+ say 'Menjalankan bundle install...'
47
+ run 'bundle install'
48
+ run 'rails generate devise:install'
49
+ inject_into_file 'config/routes.rb', " devise_for :auths, class_name: 'Models::Auth'\n", after: "Rails.application.routes.draw do\n"
50
+ end
51
+
52
+ def setup_migration
53
+ template 'db/migrate/20241117042039_devise_create_auths.rb', File.join('db/migrate/20241117042039_devise_create_auths.rb')
54
+ template 'db/migrate/20241117043154_create_models_accounts.rb', File.join('db/migrate/20241117043154_create_models_accounts.rb')
55
+ template 'db/migrate/20241117044142_create_models_users.rb', File.join('db/migrate/20241117044142_create_models_users.rb')
56
+
57
+ template 'db/seeds.rb', File.join('db/seeds.rb')
58
+ end
59
+
60
+ def setup_models
61
+ template 'models/models/account.rb', File.join('app/models/models/account.rb')
62
+ template 'models/models/auth.rb', File.join('app/models/models/auth.rb')
63
+ template 'models/models/user.rb', File.join('app/models/models/user.rb')
64
+ end
65
+
66
+ def validation!
67
+ unless File.exist?('config/initializers/sun_sword.rb')
68
+ say 'Error must create init configuration for sun_sword!'
69
+ raise Thor::Error, 'run: bin/rails generate sun_sword:init'
70
+ end
71
+ end
72
+
35
73
  def remove_assets_folder
36
74
  assets_path = "#{path_app}/assets"
37
75
  if Dir.exist?(assets_path)
@@ -47,18 +85,8 @@ module SunSword
47
85
  say "File '#{path_app}/assets' has been copied from template.", :green
48
86
  end
49
87
 
50
- def copy_database_config
51
- template 'config/database.yml', File.join('config/database.yml')
52
- end
53
-
54
- def copy_env_development
55
- template 'env.development', File.join('.env.development')
56
- template 'env.development', File.join('env.example')
57
- end
58
-
59
88
  def add_vite_to_gemfile
60
89
  gem_dependencies = <<~RUBY
61
-
62
90
  # --- SunSword Package frontend
63
91
  gem "turbo-rails"
64
92
  gem "stimulus-rails"
@@ -120,10 +148,6 @@ module SunSword
120
148
  get "site/jadi_a"
121
149
  get "site/jadi_b"
122
150
 
123
- namespace :dashboard do
124
- get "site" => "site#index", as: :dashboard_site_index
125
- end
126
-
127
151
  RUBY
128
152
  inject_into_file 'config/routes.rb', site_route, after: "Rails.application.routes.draw do\n"
129
153
 
@@ -139,9 +163,9 @@ module SunSword
139
163
  template 'views/site/_comment.html.erb.tt', 'app/views/site/_comment.html.erb'
140
164
  template 'views/layouts/application.html.erb.tt', 'app/views/layouts/application.html.erb'
141
165
 
142
- directory('views/layouts/dashboard', 'app/views/layouts/dashboard')
166
+ template 'views/layouts/dashboard/application.html.erb.tt', 'app/views/layouts/owner/application.html.erb'
167
+ template 'views/layouts/dashboard/_sidebar.html.erb.tt', 'app/views/components/layouts/_sidebar.html.erb'
143
168
  directory('helpers', 'app/helpers')
144
- template('controllers/dashboard/site_controller.rb', 'app/controllers/dashboard/site_controller.rb')
145
169
  say 'Updated application layout for Vite integration', :green
146
170
  end
147
171
  end
@@ -0,0 +1,15 @@
1
+ module SunSword
2
+ class InitGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('templates_init', __dir__)
4
+
5
+ def setup_configuration
6
+ copy_initializer('sun_sword')
7
+ end
8
+
9
+ private
10
+
11
+ def copy_initializer(file_name)
12
+ template "config/initializers/#{file_name}.rb", File.join("config/initializers/#{file_name}.rb")
13
+ end
14
+ end
15
+ end
@@ -3,6 +3,7 @@ module SunSword
3
3
  source_root File.expand_path('templates_scaffold', __dir__)
4
4
 
5
5
  argument :arg_structure, type: :string, default: '', banner: ''
6
+ argument :arg_scope, type: :hash, default: '', banner: 'scope:dashboard'
6
7
 
7
8
  def running
8
9
  validation!
@@ -16,9 +17,9 @@ module SunSword
16
17
  private
17
18
 
18
19
  def validation!
19
- unless File.exist?('config/initializers/rider_kick.rb')
20
- say 'Error must create init configuration for rider_kick!'
21
- raise Thor::Error, 'run: bin/rails generate rider_kick:init'
20
+ unless File.exist?('config/initializers/sun_sword.rb')
21
+ say 'Error must create init configuration for sun_sword!'
22
+ raise Thor::Error, 'run: bin/rails generate sun_sword:init'
22
23
  end
23
24
  end
24
25
 
@@ -43,8 +44,6 @@ module SunSword
43
44
  @contract_destroy = @services.action_destroy.use_case.contract || []
44
45
  @skipped_fields = entity.skipped_fields || []
45
46
  @custom_fields = entity.custom_fields || []
46
- @route_scope_path = @structure.controllers.route_scope.downcase rescue ''
47
- @route_scope_class = @route_scope_path.camelize rescue ''
48
47
 
49
48
  @variable_subject = model_name.split('::').last.underscore.downcase
50
49
  @scope_path = resource_name.pluralize.underscore.downcase
@@ -52,6 +51,108 @@ module SunSword
52
51
  @model_class = model_name.camelize.constantize
53
52
  @subject_class = resource_name.camelize
54
53
  @fields = contract_fields
54
+ @form_fields = @controllers.form_fields
55
+
56
+ @route_scope_path = arg_scope['scope'].to_s.downcase rescue ''
57
+ @route_scope_class = @route_scope_path.camelize rescue ''
58
+
59
+ @mapping_fields = {
60
+ string: :text_field,
61
+ text: :text_area,
62
+ integer: :number_field,
63
+ float: :number_field,
64
+ decimal: :number_field,
65
+ boolean: :check_box,
66
+ date: :date_select,
67
+ datetime: :datetime_select,
68
+ timestamp: :datetime_select,
69
+ time: :time_select,
70
+ enum: :select,
71
+ file: :file_field
72
+ }
73
+ end
74
+
75
+ def generate_form_fields_html
76
+ form_fields_html = ''
77
+ @form_fields.each do |field|
78
+ field_name = field[:name]
79
+ field_type = field[:type]
80
+ form_helper = @mapping_fields[field_type] || :text_field
81
+ input_id = "#{@variable_subject}_#{field_name}"
82
+ label_input_id = case form_helper
83
+ when :date_select, :datetime_select then "#{input_id}_1i" # Year
84
+ when :time_select then "#{input_id}_4i" # Hour
85
+ else input_id
86
+ end
87
+
88
+ field_html = <<-HTML
89
+
90
+ <div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:py-6">
91
+ <%= form.label :#{field_name}, for: '#{label_input_id}', class: "block text-sm font-medium text-gray-700 sm:pt-1.5" %>
92
+ <div class="mt-2 sm:col-span-2 sm:mt-0">
93
+ HTML
94
+
95
+ case form_helper
96
+ when :text_field, :number_field
97
+ field_html += <<-HTML
98
+ <%= form.#{form_helper} :#{field_name}, id: '#{input_id}', class: "block w-full rounded-md border-gray-300 py-1.5 text-gray-700 shadow-sm focus:ring-2 focus:ring-gray-300 focus:border-gray-300 sm:max-w-md sm:text-sm" %>
99
+ HTML
100
+ when :text_area
101
+ field_html += <<-HTML
102
+ <%= form.text_area :#{field_name}, id: '#{input_id}', rows: 3, class: "block w-full max-w-2xl rounded-md border-gray-300 py-1.5 text-gray-700 shadow-sm focus:ring-2 focus:ring-gray-300 focus:border-gray-300 sm:text-sm" %>
103
+ HTML
104
+ when :check_box
105
+ field_html += <<-HTML
106
+ <div class="relative flex items-start">
107
+ <div class="flex h-6 items-center">
108
+ <%= form.check_box :#{field_name}, id: '#{input_id}', class: "h-4 w-4 rounded border-gray-300 text-gray-600 focus:ring-gray-300 focus:border-gray-300" %>
109
+ </div>
110
+ <div class="ml-3 text-sm">
111
+ <%= form.label :#{field_name}, for: '#{input_id}', class: "font-medium text-gray-700" %>
112
+ </div>
113
+ </div>
114
+ HTML
115
+ when :select
116
+ field_html += <<-HTML
117
+ <%= form.select :#{field_name}, options_for_select([['Option 1', 1], ['Option 2', 2]]), {}, { id: '#{input_id}', class: "block w-full rounded-md border-gray-300 py-1.5 text-gray-700 shadow-sm focus:ring-2 focus:ring-gray-300 focus:border-gray-300 sm:max-w-xs sm:text-sm" } %>
118
+ HTML
119
+ when :datetime_select, :date_select, :time_select
120
+ field_html += <<-HTML
121
+ <%= form.#{form_helper} :#{field_name}, { discard_second: true, id_prefix: '#{input_id}' }, { class: "text-gray-700 shadow-sm focus:ring-2 focus:ring-gray-300 focus:border-gray-300 sm:text-sm" } %>
122
+ HTML
123
+ when :file_field
124
+ field_html += <<-HTML
125
+ <div class="flex max-w-2xl justify-center rounded-lg border border-dashed border-gray-300 px-6 py-10">
126
+ <div class="text-center">
127
+ <!-- SVG Icon -->
128
+ <svg class="mx-auto size-12 text-gray-300" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" data-slot="icon">
129
+ <path fill-rule="evenodd" d="M1.5 6a2.25 2.25 0 0 1 2.25-2.25h16.5A2.25 2.25 0 0 1 22.5 6v12a2.25 2.25 0 0 1-2.25 2.25H3.75A2.25 2.25 0 0 1 1.5 18V6ZM3 16.06V18c0 .414.336.75.75.75h16.5A.75.75 0 0 0 21 18v-1.94l-2.69-2.689a1.5 1.5 0 0 0-2.12 0l-.88.879.97.97a.75.75 0 1 1-1.06 1.06l-5.16-5.159a1.5 1.5 0 0 0-2.12 0L3 16.061Zm10.125-7.81a1.125 1.125 0 1 1 2.25 0 1.125 1.125 0 0 1-2.25 0Z" clip-rule="evenodd" />
130
+ </svg>
131
+ <div class="mt-4 flex text-sm text-gray-600">
132
+ <label for="<%= '#{input_id}' %>" class="relative cursor-pointer rounded-md bg-white font-semibold text-gray-600 hover:text-gray-500">
133
+ <span>Upload a file</span>
134
+ <%= form.file_field :#{field_name}, id: '#{input_id}', class: "sr-only" %>
135
+ </label>
136
+ <p class="pl-1">or drag and drop</p>
137
+ </div>
138
+ <p class="text-xs text-gray-600">PNG, JPG, GIF, DOC etc.</p>
139
+ </div>
140
+ </div>
141
+ HTML
142
+ else
143
+ field_html += <<-HTML
144
+ <%= form.#{form_helper} :#{field_name}, id: '#{input_id}', class: "block w-full rounded-md border-gray-300 py-1.5 text-gray-700 shadow-sm focus:ring-2 focus:ring-gray-300 focus:border-gray-300 sm:max-w-md sm:text-sm" %>
145
+ HTML
146
+ end
147
+
148
+ field_html += <<-HTML
149
+ </div>
150
+ </div>
151
+ HTML
152
+
153
+ form_fields_html += field_html
154
+ end
155
+ form_fields_html
55
156
  end
56
157
 
57
158
  def build_usecase_filename(action, suffix = '')
@@ -67,6 +168,7 @@ module SunSword
67
168
  end
68
169
 
69
170
  def create_view_file
171
+ @form_fields_html = generate_form_fields_html
70
172
  template 'views/_form.html.erb.tt', File.join('app/views', @route_scope_path.to_s, @scope_path.to_s, '_form.html.erb')
71
173
  template 'views/edit.html.erb.tt', File.join('app/views', @route_scope_path.to_s, @scope_path.to_s, 'edit.html.erb')
72
174
  template 'views/index.html.erb.tt', File.join('app/views', @route_scope_path.to_s, @scope_path.to_s, 'index.html.erb')
@@ -74,23 +176,47 @@ module SunSword
74
176
  template 'views/show.html.erb.tt', File.join('app/views', @route_scope_path.to_s, @scope_path.to_s, 'show.html.erb')
75
177
  end
76
178
 
179
+ def namespace_exists?
180
+ routes_file = 'config/routes.rb'
181
+ scope_pattern = "namespace :#{@route_scope_path} do\n"
182
+ if File.exist?(routes_file)
183
+ file_content = File.read(routes_file)
184
+ file_content.include?(scope_pattern)
185
+ else
186
+ false
187
+ end
188
+ end
189
+
77
190
  def create_link_file
78
191
  template 'views/components/menu/link.html.erb.tt', File.join('app/views/components/menu', "_link_to_#{@scope_path}.html.erb")
79
192
  link_to = " <li><%= render 'components/menu/#{"link_to_#{@scope_path}"}' %></li>\n"
80
- inject_into_file 'app/views/layouts/dashboard/_sidebar.html.erb', link_to, before: " <%# generate_link %>\n"
193
+ inject_into_file 'app/views/components/layouts/_sidebar.html.erb', link_to, before: " <%# generate_link %>\n"
194
+ routes_file = 'config/routes.rb'
195
+ if !namespace_exists? && @route_scope_path.present?
196
+ scope_code = <<-RUBY
197
+ namespace :#{@route_scope_path} do
198
+ end
199
+ RUBY
200
+ insert_into_file routes_file, scope_code, after: "Rails.application.routes.draw do\n"
201
+ end
202
+ if @route_scope_path.present?
203
+ inject_into_file routes_file, " resources :#{@scope_path}\n", after: "namespace :#{@route_scope_path} do\n"
204
+ else
205
+ inject_into_file routes_file, " resources :#{@scope_path}\n", after: "Rails.application.routes.draw do\n"
206
+ end
81
207
  end
82
208
 
83
209
  def contract_fields
84
210
  skip_contract_fields = @skipped_fields.map(&:strip).uniq
85
- if RiderKick.scope_owner_column.present?
86
- skip_contract_fields << RiderKick.scope_owner_column.to_s
211
+ if SunSword.scope_owner_column.present?
212
+ skip_contract_fields << SunSword.scope_owner_column.to_s
87
213
  end
88
214
  @model_class.columns.reject { |column| skip_contract_fields.include?(column.name.to_s) }.map(&:name).map(&:to_s)
89
215
  end
90
216
 
91
217
  def strong_params
92
218
  results = ''
93
- @controllers.form_fields.map { |tc| results << ":#{tc}," }
219
+ @controllers.form_fields.map { |tc| results << ":#{tc.name}, " }
94
220
  results[0..-2]
95
221
  end
96
222
  end
@@ -0,0 +1,313 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Assuming you have not yet modified this file, each configuration option below
4
+ # is set to its default value. Note that some are commented out while others
5
+ # are not: uncommented lines are intended to protect your configuration from
6
+ # breaking changes in upgrades (i.e., in the event that future versions of
7
+ # Devise change the default values for those options).
8
+ #
9
+ # Use this hook to configure devise mailer, warden hooks and so forth.
10
+ # Many of these configuration options can be set straight in your model.
11
+ Devise.setup do |config|
12
+ # The secret key used by Devise. Devise uses this key to generate
13
+ # random tokens. Changing this key will render invalid all existing
14
+ # confirmation, reset password and unlock tokens in the database.
15
+ # Devise will use the `secret_key_base` as its `secret_key`
16
+ # by default. You can change it below and use your own secret key.
17
+ # config.secret_key = '15930dd1ce83086d9191b621b8e19208f021ada98fcb3264bb0c0fc5150c5988d663dccf08e0b6b297f934f7a29fa55cee5bd62a7a513622b81c7c9e736aba9f'
18
+
19
+ # ==> Controller configuration
20
+ # Configure the parent class to the devise controllers.
21
+ # config.parent_controller = 'DeviseController'
22
+
23
+ # ==> Mailer Configuration
24
+ # Configure the e-mail address which will be shown in Devise::Mailer,
25
+ # note that it will be overwritten if you use your own mailer class
26
+ # with default "from" parameter.
27
+ config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
28
+
29
+ # Configure the class responsible to send e-mails.
30
+ # config.mailer = 'Devise::Mailer'
31
+
32
+ # Configure the parent class responsible to send e-mails.
33
+ # config.parent_mailer = 'ActionMailer::Base'
34
+
35
+ # ==> ORM configuration
36
+ # Load and configure the ORM. Supports :active_record (default) and
37
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
38
+ # available as additional gems.
39
+ require 'devise/orm/active_record'
40
+
41
+ # ==> Configuration for any authentication mechanism
42
+ # Configure which keys are used when authenticating a user. The default is
43
+ # just :email. You can configure it to use [:username, :subdomain], so for
44
+ # authenticating a user, both parameters are required. Remember that those
45
+ # parameters are used only when authenticating and not when retrieving from
46
+ # session. If you need permissions, you should implement that in a before filter.
47
+ # You can also supply a hash where the value is a boolean determining whether
48
+ # or not authentication should be aborted when the value is not present.
49
+ # config.authentication_keys = [:email]
50
+
51
+ # Configure parameters from the request object used for authentication. Each entry
52
+ # given should be a request method and it will automatically be passed to the
53
+ # find_for_authentication method and considered in your model lookup. For instance,
54
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
55
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
56
+ # config.request_keys = []
57
+
58
+ # Configure which authentication keys should be case-insensitive.
59
+ # These keys will be downcased upon creating or modifying a user and when used
60
+ # to authenticate or find a user. Default is :email.
61
+ config.case_insensitive_keys = [:email]
62
+
63
+ # Configure which authentication keys should have whitespace stripped.
64
+ # These keys will have whitespace before and after removed upon creating or
65
+ # modifying a user and when used to authenticate or find a user. Default is :email.
66
+ config.strip_whitespace_keys = [:email]
67
+
68
+ # Tell if authentication through request.params is enabled. True by default.
69
+ # It can be set to an array that will enable params authentication only for the
70
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
71
+ # enable it only for database (email + password) authentication.
72
+ # config.params_authenticatable = true
73
+
74
+ # Tell if authentication through HTTP Auth is enabled. False by default.
75
+ # It can be set to an array that will enable http authentication only for the
76
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
77
+ # enable it only for database authentication.
78
+ # For API-only applications to support authentication "out-of-the-box", you will likely want to
79
+ # enable this with :database unless you are using a custom strategy.
80
+ # The supported strategies are:
81
+ # :database = Support basic authentication with authentication key + password
82
+ # config.http_authenticatable = false
83
+
84
+ # If 401 status code should be returned for AJAX requests. True by default.
85
+ # config.http_authenticatable_on_xhr = true
86
+
87
+ # The realm used in Http Basic Authentication. 'Application' by default.
88
+ # config.http_authentication_realm = 'Application'
89
+
90
+ # It will change confirmation, password recovery and other workflows
91
+ # to behave the same regardless if the e-mail provided was right or wrong.
92
+ # Does not affect registerable.
93
+ # config.paranoid = true
94
+
95
+ # By default Devise will store the user in session. You can skip storage for
96
+ # particular strategies by setting this option.
97
+ # Notice that if you are skipping storage for all authentication paths, you
98
+ # may want to disable generating routes to Devise's sessions controller by
99
+ # passing skip: :sessions to `devise_for` in your config/routes.rb
100
+ config.skip_session_storage = [:http_auth]
101
+
102
+ # By default, Devise cleans up the CSRF token on authentication to
103
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
104
+ # requests for sign in and sign up, you need to get a new CSRF token
105
+ # from the server. You can disable this option at your own risk.
106
+ # config.clean_up_csrf_token_on_authentication = true
107
+
108
+ # When false, Devise will not attempt to reload routes on eager load.
109
+ # This can reduce the time taken to boot the app but if your application
110
+ # requires the Devise mappings to be loaded during boot time the application
111
+ # won't boot properly.
112
+ # config.reload_routes = true
113
+
114
+ # ==> Configuration for :database_authenticatable
115
+ # For bcrypt, this is the cost for hashing the password and defaults to 12. If
116
+ # using other algorithms, it sets how many times you want the password to be hashed.
117
+ # The number of stretches used for generating the hashed password are stored
118
+ # with the hashed password. This allows you to change the stretches without
119
+ # invalidating existing passwords.
120
+ #
121
+ # Limiting the stretches to just one in testing will increase the performance of
122
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
123
+ # a value less than 10 in other environments. Note that, for bcrypt (the default
124
+ # algorithm), the cost increases exponentially with the number of stretches (e.g.
125
+ # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
126
+ config.stretches = Rails.env.test? ? 1 : 12
127
+
128
+ # Set up a pepper to generate the hashed password.
129
+ # config.pepper = '03a3aa57eb88dc6caa0afb067aba22d84c6737569ccb2bfae0ab30441b2a5618467ee85fead9a4c6d1ec56ad962596765837abec68aa91e994e5117c183bf162'
130
+
131
+ # Send a notification to the original email when the user's email is changed.
132
+ # config.send_email_changed_notification = false
133
+
134
+ # Send a notification email when the user's password is changed.
135
+ # config.send_password_change_notification = false
136
+
137
+ # ==> Configuration for :confirmable
138
+ # A period that the user is allowed to access the website even without
139
+ # confirming their account. For instance, if set to 2.days, the user will be
140
+ # able to access the website for two days without confirming their account,
141
+ # access will be blocked just in the third day.
142
+ # You can also set it to nil, which will allow the user to access the website
143
+ # without confirming their account.
144
+ # Default is 0.days, meaning the user cannot access the website without
145
+ # confirming their account.
146
+ # config.allow_unconfirmed_access_for = 2.days
147
+
148
+ # A period that the user is allowed to confirm their account before their
149
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
150
+ # their account within 3 days after the mail was sent, but on the fourth day
151
+ # their account can't be confirmed with the token any more.
152
+ # Default is nil, meaning there is no restriction on how long a user can take
153
+ # before confirming their account.
154
+ # config.confirm_within = 3.days
155
+
156
+ # If true, requires any email changes to be confirmed (exactly the same way as
157
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
158
+ # db field (see migrations). Until confirmed, new email is stored in
159
+ # unconfirmed_email column, and copied to email column on successful confirmation.
160
+ config.reconfirmable = true
161
+
162
+ # Defines which key will be used when confirming an account
163
+ # config.confirmation_keys = [:email]
164
+
165
+ # ==> Configuration for :rememberable
166
+ # The time the user will be remembered without asking for credentials again.
167
+ # config.remember_for = 2.weeks
168
+
169
+ # Invalidates all the remember me tokens when the user signs out.
170
+ config.expire_all_remember_me_on_sign_out = true
171
+
172
+ # If true, extends the user's remember period when remembered via cookie.
173
+ # config.extend_remember_period = false
174
+
175
+ # Options to be passed to the created cookie. For instance, you can set
176
+ # secure: true in order to force SSL only cookies.
177
+ # config.rememberable_options = {}
178
+
179
+ # ==> Configuration for :validatable
180
+ # Range for password length.
181
+ config.password_length = 6..128
182
+
183
+ # Email regex used to validate email formats. It simply asserts that
184
+ # one (and only one) @ exists in the given string. This is mainly
185
+ # to give user feedback and not to assert the e-mail validity.
186
+ config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
187
+
188
+ # ==> Configuration for :timeoutable
189
+ # The time you want to timeout the user session without activity. After this
190
+ # time the user will be asked for credentials again. Default is 30 minutes.
191
+ # config.timeout_in = 30.minutes
192
+
193
+ # ==> Configuration for :lockable
194
+ # Defines which strategy will be used to lock an account.
195
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
196
+ # :none = No lock strategy. You should handle locking by yourself.
197
+ # config.lock_strategy = :failed_attempts
198
+
199
+ # Defines which key will be used when locking and unlocking an account
200
+ # config.unlock_keys = [:email]
201
+
202
+ # Defines which strategy will be used to unlock an account.
203
+ # :email = Sends an unlock link to the user email
204
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
205
+ # :both = Enables both strategies
206
+ # :none = No unlock strategy. You should handle unlocking by yourself.
207
+ # config.unlock_strategy = :both
208
+
209
+ # Number of authentication tries before locking an account if lock_strategy
210
+ # is failed attempts.
211
+ # config.maximum_attempts = 20
212
+
213
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
214
+ # config.unlock_in = 1.hour
215
+
216
+ # Warn on the last attempt before the account is locked.
217
+ # config.last_attempt_warning = true
218
+
219
+ # ==> Configuration for :recoverable
220
+ #
221
+ # Defines which key will be used when recovering the password for an account
222
+ # config.reset_password_keys = [:email]
223
+
224
+ # Time interval you can reset your password with a reset password key.
225
+ # Don't put a too small interval or your users won't have the time to
226
+ # change their passwords.
227
+ config.reset_password_within = 6.hours
228
+
229
+ # When set to false, does not sign a user in automatically after their password is
230
+ # reset. Defaults to true, so a user is signed in automatically after a reset.
231
+ # config.sign_in_after_reset_password = true
232
+
233
+ # ==> Configuration for :encryptable
234
+ # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
235
+ # You can use :sha1, :sha512 or algorithms from others authentication tools as
236
+ # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
237
+ # for default behavior) and :restful_authentication_sha1 (then you should set
238
+ # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
239
+ #
240
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
241
+ # config.encryptor = :sha512
242
+
243
+ # ==> Scopes configuration
244
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
245
+ # "users/sessions/new". It's turned off by default because it's slower if you
246
+ # are using only default views.
247
+ # config.scoped_views = false
248
+
249
+ # Configure the default scope given to Warden. By default it's the first
250
+ # devise role declared in your routes (usually :user).
251
+ # config.default_scope = :user
252
+
253
+ # Set this configuration to false if you want /users/sign_out to sign out
254
+ # only the current scope. By default, Devise signs out all scopes.
255
+ # config.sign_out_all_scopes = true
256
+
257
+ # ==> Navigation configuration
258
+ # Lists the formats that should be treated as navigational. Formats like
259
+ # :html should redirect to the sign in page when the user does not have
260
+ # access, but formats like :xml or :json, should return 401.
261
+ #
262
+ # If you have any extra navigational formats, like :iphone or :mobile, you
263
+ # should add them to the navigational formats lists.
264
+ #
265
+ # The "*/*" below is required to match Internet Explorer requests.
266
+ # config.navigational_formats = ['*/*', :html, :turbo_stream]
267
+
268
+ # The default HTTP method used to sign out a resource. Default is :delete.
269
+ config.sign_out_via = :get
270
+
271
+ # ==> OmniAuth
272
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
273
+ # up on your models and hooks.
274
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
275
+
276
+ # ==> Warden configuration
277
+ # If you want to use other strategies, that are not supported by Devise, or
278
+ # change the failure app, you can configure them inside the config.warden block.
279
+ #
280
+ # config.warden do |manager|
281
+ # manager.intercept_401 = false
282
+ # manager.default_strategies(scope: :user).unshift :some_external_strategy
283
+ # end
284
+
285
+ # ==> Mountable engine configurations
286
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
287
+ # is mountable, there are some extra configurations to be taken into account.
288
+ # The following options are available, assuming the engine is mounted as:
289
+ #
290
+ # mount MyEngine, at: '/my_engine'
291
+ #
292
+ # The router that invoked `devise_for`, in the example above, would be:
293
+ # config.router_name = :my_engine
294
+ #
295
+ # When using OmniAuth, Devise cannot automatically set OmniAuth path,
296
+ # so you need to do it manually. For the users scope, it would be:
297
+ # config.omniauth_path_prefix = '/my_engine/users/auth'
298
+
299
+ # ==> Hotwire/Turbo configuration
300
+ # When using Devise with Hotwire/Turbo, the http status for error responses
301
+ # and some redirects must match the following. The default in Devise for existing
302
+ # apps is `200 OK` and `302 Found` respectively, but new apps are generated with
303
+ # these new defaults that match Hotwire/Turbo behavior.
304
+ # Note: These might become the new default in future versions of Devise.
305
+ config.responder.error_status = :unprocessable_entity
306
+ config.responder.redirect_status = :see_other
307
+
308
+ # ==> Configuration for :registerable
309
+
310
+ # When set to false, does not sign a user in automatically after their password is
311
+ # changed. Defaults to true, so a user is signed in automatically after changing a password.
312
+ # config.sign_in_after_change_password = true
313
+ end