propel_authentication 0.1.2 → 0.1.4
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +87 -0
- data/README.md +251 -113
- data/lib/generators/{propel_auth → propel_authentication}/install_generator.rb +89 -93
- data/lib/generators/{propel_auth → propel_authentication}/templates/auth_mailer.rb +1 -1
- data/lib/generators/{propel_auth → propel_authentication}/templates/authenticatable.rb +3 -3
- data/lib/generators/{propel_auth → propel_authentication}/templates/concerns/confirmable.rb +2 -2
- data/lib/generators/{propel_auth → propel_authentication}/templates/concerns/lockable.rb +6 -6
- data/lib/generators/{propel_auth → propel_authentication}/templates/concerns/recoverable.rb +6 -6
- data/lib/generators/propel_authentication/templates/core/configuration_methods.rb +151 -0
- data/lib/generators/{propel_auth → propel_authentication}/templates/invitation.rb +2 -2
- data/lib/generators/{propel_auth/templates/propel_auth.rb → propel_authentication/templates/propel_authentication.rb.tt} +18 -17
- data/lib/generators/{propel_auth → propel_authentication}/templates/test/concerns/lockable_test.rb.tt +12 -12
- data/lib/generators/{propel_auth → propel_authentication}/templates/test/concerns/propel_authentication_test.rb.tt +1 -1
- data/lib/generators/{propel_auth → propel_authentication}/templates/test/concerns/recoverable_test.rb.tt +7 -7
- data/lib/generators/{propel_auth → propel_authentication}/templates/user_test.rb.tt +1 -1
- data/lib/generators/{propel_auth → propel_authentication}/unpack_generator.rb +38 -25
- data/lib/propel_authentication.rb +3 -0
- metadata +98 -99
- data/lib/generators/propel_auth/pack_generator.rb +0 -277
- data/lib/generators/propel_auth/templates/lib/propel_auth.rb +0 -84
- data/lib/generators/propel_auth/test/dummy/Gemfile.lock +0 -394
- data/lib/propel_auth.rb +0 -3
- /data/lib/generators/{propel_auth → propel_authentication}/templates/agency.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/agent.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/auth/base_passwords_controller.rb.tt +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/auth/base_tokens_controller.rb.tt +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/auth/passwords_controller.rb.tt +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/concerns/propel_authentication.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/concerns/rack_session_disable.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/config/environments/development_email.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/db/migrate/create_agencies.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/db/migrate/create_agents.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/db/migrate/create_invitations.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/db/migrate/create_organizations.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/db/migrate/create_users.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/db/seeds.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/organization.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/services/auth_notification_service.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/test/concerns/confirmable_test.rb.tt +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/test/controllers/auth/lockable_integration_test.rb.tt +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/test/controllers/auth/password_reset_integration_test.rb.tt +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/test/controllers/auth/tokens_controller_test.rb.tt +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/test/mailers/auth_mailer_test.rb.tt +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/test/mailers/previews/auth_mailer_preview.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/tokens_controller.rb.tt +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/user.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/views/auth_mailer/account_unlock.html.erb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/views/auth_mailer/account_unlock.text.erb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/views/auth_mailer/email_confirmation.html.erb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/views/auth_mailer/email_confirmation.text.erb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/views/auth_mailer/password_reset.html.erb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/views/auth_mailer/password_reset.text.erb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/views/auth_mailer/user_invitation.html.erb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/templates/views/auth_mailer/user_invitation.text.erb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/Dockerfile +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/Gemfile +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/README.md +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/Rakefile +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/app/assets/stylesheets/application.css +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/app/controllers/application_controller.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/app/helpers/application_helper.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/app/jobs/application_job.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/app/mailers/application_mailer.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/app/models/application_record.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/app/views/layouts/application.html.erb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/app/views/layouts/mailer.html.erb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/app/views/layouts/mailer.text.erb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/app/views/pwa/manifest.json.erb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/app/views/pwa/service-worker.js +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/bin/brakeman +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/bin/dev +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/bin/docker-entrypoint +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/bin/rails +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/bin/rake +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/bin/rubocop +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/bin/setup +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/bin/thrust +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/application.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/boot.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/cable.yml +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/credentials.yml.enc +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/database.yml +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/environment.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/environments/development.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/environments/production.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/environments/test.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/initializers/assets.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/initializers/content_security_policy.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/initializers/filter_parameter_logging.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/initializers/inflections.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/locales/en.yml +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/master.key +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/puma.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/routes.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config/storage.yml +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/config.ru +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/dummy/db/schema.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/generators/authentication/controllers/tokens_controller_test.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/generators/authentication/install_generator_test.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/generators/authentication/uninstall_generator_test.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/integration/generator_integration_test.rb +0 -0
- /data/lib/generators/{propel_auth → propel_authentication}/test/integration/multi_version_generator_test.rb +0 -0
@@ -1,277 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
##
|
4
|
-
# PropelAuth packer that bundles customized authentication code back into gem format
|
5
|
-
#
|
6
|
-
# Usage:
|
7
|
-
# rails generate propel_auth:pack # Pack all customized code
|
8
|
-
# rails generate propel_auth:pack --output-dir=../gems # Pack to specific directory
|
9
|
-
# rails generate propel_auth:pack --version=0.2.0 # Pack with custom version
|
10
|
-
#
|
11
|
-
# This bundles your customized PropelAuth generator and templates back into a
|
12
|
-
# distributable gem format for sharing across projects or organizations.
|
13
|
-
#
|
14
|
-
class PropelAuth::PackGenerator < Rails::Generators::Base
|
15
|
-
desc "Pack customized PropelAuth code back into distributable gem format"
|
16
|
-
|
17
|
-
class_option :output_dir,
|
18
|
-
type: :string,
|
19
|
-
default: "tmp/propel_auth_custom",
|
20
|
-
desc: "Output directory for packed gem"
|
21
|
-
|
22
|
-
class_option :version,
|
23
|
-
type: :string,
|
24
|
-
default: "0.1.0-custom",
|
25
|
-
desc: "Version for the packed gem"
|
26
|
-
|
27
|
-
class_option :gem_name,
|
28
|
-
type: :string,
|
29
|
-
default: "propel_auth_custom",
|
30
|
-
desc: "Name for the packed gem"
|
31
|
-
|
32
|
-
def pack_propel_auth_generator
|
33
|
-
@output_dir = options[:output_dir]
|
34
|
-
@version = options[:version]
|
35
|
-
@gem_name = options[:gem_name]
|
36
|
-
|
37
|
-
show_welcome_message
|
38
|
-
validate_source_files
|
39
|
-
create_gem_structure
|
40
|
-
copy_generator_logic
|
41
|
-
copy_templates
|
42
|
-
create_gemspec
|
43
|
-
create_readme
|
44
|
-
show_completion_message
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def show_welcome_message
|
50
|
-
say ""
|
51
|
-
say "╔══════════════════════════════════════╗", :cyan
|
52
|
-
say "║ PACK PROPEL AUTH GENERATOR ║", :cyan
|
53
|
-
say "╚══════════════════════════════════════╝", :cyan
|
54
|
-
say ""
|
55
|
-
say "Packing your customized PropelAuth code into distributable gem format", :blue
|
56
|
-
say ""
|
57
|
-
say "📁 FROM: lib/generators/propel_auth/ (customized)", :yellow
|
58
|
-
say "📦 TO: #{@output_dir}/ (distributable gem)", :green
|
59
|
-
say ""
|
60
|
-
end
|
61
|
-
|
62
|
-
def validate_source_files
|
63
|
-
source_path = "lib/generators/propel_auth"
|
64
|
-
|
65
|
-
unless File.exist?(source_path)
|
66
|
-
raise Thor::Error, "❌ No customized PropelAuth generator found at #{source_path}. Run 'rails generate propel_auth:unpack' first."
|
67
|
-
end
|
68
|
-
|
69
|
-
required_files = %w[install_generator.rb]
|
70
|
-
missing_files = required_files.reject { |file| File.exist?(File.join(source_path, file)) }
|
71
|
-
|
72
|
-
if missing_files.any?
|
73
|
-
raise Thor::Error, "❌ Missing required files: #{missing_files.join(', ')}"
|
74
|
-
end
|
75
|
-
|
76
|
-
say "✅ Source files validated", :green
|
77
|
-
end
|
78
|
-
|
79
|
-
def create_gem_structure
|
80
|
-
FileUtils.mkdir_p(File.join(@output_dir, "lib", @gem_name))
|
81
|
-
FileUtils.mkdir_p(File.join(@output_dir, "lib", "generators", @gem_name))
|
82
|
-
say "📁 Created gem directory structure", :blue
|
83
|
-
end
|
84
|
-
|
85
|
-
def copy_generator_logic
|
86
|
-
source_path = "lib/generators/propel_auth"
|
87
|
-
dest_path = File.join(@output_dir, "lib", "generators", @gem_name)
|
88
|
-
|
89
|
-
# Copy install generator
|
90
|
-
if File.exist?(File.join(source_path, "install_generator.rb"))
|
91
|
-
source_content = File.read(File.join(source_path, "install_generator.rb"))
|
92
|
-
|
93
|
-
# Update module name for custom gem
|
94
|
-
modified_content = source_content.gsub(
|
95
|
-
/^module PropelAuth$/,
|
96
|
-
"module #{@gem_name.camelize}"
|
97
|
-
)
|
98
|
-
|
99
|
-
File.write(File.join(dest_path, "install_generator.rb"), modified_content)
|
100
|
-
say " ✅ Install generator packed", :green
|
101
|
-
end
|
102
|
-
|
103
|
-
# Create unpack generator for the custom gem
|
104
|
-
create_unpack_generator(dest_path)
|
105
|
-
end
|
106
|
-
|
107
|
-
def copy_templates
|
108
|
-
source_templates = "lib/generators/propel_auth/templates"
|
109
|
-
dest_templates = File.join(@output_dir, "lib", "generators", @gem_name, "templates")
|
110
|
-
|
111
|
-
if Dir.exist?(source_templates)
|
112
|
-
FileUtils.cp_r(source_templates, dest_templates)
|
113
|
-
say " ✅ Templates packed", :green
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def create_gemspec
|
118
|
-
gemspec_content = <<~GEMSPEC
|
119
|
-
# frozen_string_literal: true
|
120
|
-
|
121
|
-
require_relative "lib/#{@gem_name}/version"
|
122
|
-
|
123
|
-
Gem::Specification.new do |spec|
|
124
|
-
spec.name = "#{@gem_name}"
|
125
|
-
spec.version = #{@gem_name.camelize}::VERSION
|
126
|
-
spec.authors = ["#{`git config user.name`.strip}"]
|
127
|
-
spec.email = ["#{`git config user.email`.strip}"]
|
128
|
-
|
129
|
-
spec.summary = "Customized PropelAuth authentication system"
|
130
|
-
spec.description = "Self-extracting authentication gem based on PropelAuth with custom modifications"
|
131
|
-
spec.homepage = "https://github.com/yourorg/#{@gem_name}"
|
132
|
-
spec.license = "MIT"
|
133
|
-
|
134
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
135
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
136
|
-
spec.metadata["changelog_uri"] = "\#{spec.homepage}/blob/main/CHANGELOG.md"
|
137
|
-
|
138
|
-
spec.files = Dir.chdir(__dir__) do
|
139
|
-
`git ls-files -z`.split("\\x0").reject do |f|
|
140
|
-
(File.expand_path(f) == __FILE__) ||
|
141
|
-
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
spec.bindir = "exe"
|
146
|
-
spec.executables = spec.files.grep(%r{\\Aexe/}) { |f| File.basename(f) }
|
147
|
-
spec.require_paths = ["lib"]
|
148
|
-
|
149
|
-
spec.add_dependency "rails", ">= 7.0"
|
150
|
-
spec.add_development_dependency "rake", "~> 13.0"
|
151
|
-
end
|
152
|
-
GEMSPEC
|
153
|
-
|
154
|
-
File.write(File.join(@output_dir, "#{@gem_name}.gemspec"), gemspec_content)
|
155
|
-
|
156
|
-
# Create version file
|
157
|
-
version_content = <<~VERSION
|
158
|
-
# frozen_string_literal: true
|
159
|
-
|
160
|
-
module #{@gem_name.camelize}
|
161
|
-
VERSION = "#{@version}"
|
162
|
-
end
|
163
|
-
VERSION
|
164
|
-
|
165
|
-
FileUtils.mkdir_p(File.join(@output_dir, "lib", @gem_name))
|
166
|
-
File.write(File.join(@output_dir, "lib", @gem_name, "version.rb"), version_content)
|
167
|
-
|
168
|
-
# Create main gem file
|
169
|
-
main_file_content = <<~MAIN
|
170
|
-
# frozen_string_literal: true
|
171
|
-
|
172
|
-
require_relative "#{@gem_name}/version"
|
173
|
-
|
174
|
-
module #{@gem_name.camelize}
|
175
|
-
# Self-extracting gem - no runtime code here
|
176
|
-
# All functionality is copied to host app during installation
|
177
|
-
end
|
178
|
-
MAIN
|
179
|
-
|
180
|
-
File.write(File.join(@output_dir, "lib", "#{@gem_name}.rb"), main_file_content)
|
181
|
-
|
182
|
-
say " ✅ Gemspec and gem files created", :green
|
183
|
-
end
|
184
|
-
|
185
|
-
def create_unpack_generator(dest_path)
|
186
|
-
unpack_content = <<~UNPACK
|
187
|
-
# frozen_string_literal: true
|
188
|
-
|
189
|
-
class #{@gem_name.camelize}::UnpackGenerator < Rails::Generators::Base
|
190
|
-
source_root File.expand_path("templates", __dir__)
|
191
|
-
|
192
|
-
desc "Extract #{@gem_name} generator to lib/generators/#{@gem_name}/ for customization"
|
193
|
-
|
194
|
-
def unpack_generator
|
195
|
-
destination_path = "lib/generators/#{@gem_name}"
|
196
|
-
|
197
|
-
if File.exist?(destination_path) && !options[:force]
|
198
|
-
say "⚠️ \#{destination_path} already exists (use --force to overwrite)", :yellow
|
199
|
-
return
|
200
|
-
end
|
201
|
-
|
202
|
-
say "📦 Extracting #{@gem_name} generator...", :green
|
203
|
-
|
204
|
-
# Copy install generator
|
205
|
-
copy_file "install_generator.rb", "\#{destination_path}/install_generator.rb"
|
206
|
-
|
207
|
-
# Copy all templates
|
208
|
-
directory ".", "\#{destination_path}/templates"
|
209
|
-
|
210
|
-
say "✅ #{@gem_name} generator extracted to \#{destination_path}/", :green
|
211
|
-
end
|
212
|
-
end
|
213
|
-
UNPACK
|
214
|
-
|
215
|
-
File.write(File.join(dest_path, "unpack_generator.rb"), unpack_content)
|
216
|
-
end
|
217
|
-
|
218
|
-
def create_readme
|
219
|
-
readme_content = <<~README
|
220
|
-
# #{@gem_name.humanize}
|
221
|
-
|
222
|
-
Custom authentication gem based on PropelAuth with organization-specific modifications.
|
223
|
-
|
224
|
-
## Installation
|
225
|
-
|
226
|
-
Add this line to your application's Gemfile:
|
227
|
-
|
228
|
-
```ruby
|
229
|
-
gem '#{@gem_name}'
|
230
|
-
```
|
231
|
-
|
232
|
-
## Usage
|
233
|
-
|
234
|
-
### Install (One-time setup)
|
235
|
-
```bash
|
236
|
-
rails generate #{@gem_name}:install
|
237
|
-
```
|
238
|
-
|
239
|
-
### Unpack for customization
|
240
|
-
```bash
|
241
|
-
rails generate #{@gem_name}:unpack
|
242
|
-
```
|
243
|
-
|
244
|
-
## Development
|
245
|
-
|
246
|
-
This gem was created by packing a customized PropelAuth installation.
|
247
|
-
|
248
|
-
## License
|
249
|
-
|
250
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
251
|
-
README
|
252
|
-
|
253
|
-
File.write(File.join(@output_dir, "README.md"), readme_content)
|
254
|
-
say " ✅ README created", :green
|
255
|
-
end
|
256
|
-
|
257
|
-
def show_completion_message
|
258
|
-
say ""
|
259
|
-
say "🎉 PropelAuth PACKED successfully!", :green
|
260
|
-
say ""
|
261
|
-
say "📦 Custom gem created at: #{@output_dir}/", :bold
|
262
|
-
say ""
|
263
|
-
|
264
|
-
say "🚀 Next steps:", :yellow
|
265
|
-
say " 1. cd #{@output_dir}"
|
266
|
-
say " 2. gem build #{@gem_name}.gemspec"
|
267
|
-
say " 3. gem install #{@gem_name}-#{@version}.gem"
|
268
|
-
say " 4. Use in other projects: gem '#{@gem_name}'"
|
269
|
-
say ""
|
270
|
-
|
271
|
-
say "💡 Your custom gem includes:", :blue
|
272
|
-
say " • Your customized install generator"
|
273
|
-
say " • All your modified templates"
|
274
|
-
say " • Unpack generator for further customization"
|
275
|
-
say " • Self-extracting architecture (no runtime dependencies)"
|
276
|
-
end
|
277
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module PropelAuth
|
4
|
-
# PropelAuth configuration and error classes
|
5
|
-
# This file was generated by PropelAuth and contains runtime functionality
|
6
|
-
# that was extracted from the gem to your application for customization.
|
7
|
-
|
8
|
-
class Error < StandardError; end
|
9
|
-
|
10
|
-
class << self
|
11
|
-
def configuration
|
12
|
-
@configuration ||= Configuration.new
|
13
|
-
end
|
14
|
-
|
15
|
-
def configure
|
16
|
-
yield(configuration)
|
17
|
-
end
|
18
|
-
|
19
|
-
def reset_configuration!
|
20
|
-
@configuration = nil
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class Configuration
|
25
|
-
attr_accessor :jwt_secret,
|
26
|
-
:jwt_expiration,
|
27
|
-
:jwt_algorithm,
|
28
|
-
:password_length,
|
29
|
-
:allow_registration,
|
30
|
-
:require_email_confirmation,
|
31
|
-
:confirmation_period,
|
32
|
-
:confirmation_resend_interval,
|
33
|
-
:max_failed_attempts,
|
34
|
-
:lockout_duration,
|
35
|
-
:password_reset_expiration,
|
36
|
-
:password_reset_rate_limit,
|
37
|
-
:frontend_url,
|
38
|
-
:email_from_address,
|
39
|
-
:support_email,
|
40
|
-
:enable_email_notifications,
|
41
|
-
:enable_sms_notifications,
|
42
|
-
:api_version
|
43
|
-
|
44
|
-
def initialize
|
45
|
-
# JWT Configuration defaults
|
46
|
-
@jwt_secret = nil # Will be set in initializer
|
47
|
-
@jwt_expiration = 24.hours
|
48
|
-
@jwt_algorithm = 'HS256'
|
49
|
-
|
50
|
-
# Password requirements
|
51
|
-
@password_length = 8..128
|
52
|
-
|
53
|
-
# User registration settings
|
54
|
-
@allow_registration = true
|
55
|
-
|
56
|
-
# Email confirmation settings
|
57
|
-
@require_email_confirmation = false
|
58
|
-
@confirmation_period = 24.hours # How long confirmation tokens are valid
|
59
|
-
@confirmation_resend_interval = 1.minute # Minimum time between resend attempts
|
60
|
-
|
61
|
-
# Account lockout settings
|
62
|
-
@max_failed_attempts = 10
|
63
|
-
@lockout_duration = 30.minutes
|
64
|
-
|
65
|
-
# Password reset settings
|
66
|
-
@password_reset_expiration = 15.minutes
|
67
|
-
@password_reset_rate_limit = 1.minute
|
68
|
-
|
69
|
-
# Frontend URL for email links (configure for your frontend application)
|
70
|
-
@frontend_url = Rails.env.development? ? 'http://localhost:3000' : nil
|
71
|
-
|
72
|
-
# Email configuration
|
73
|
-
@email_from_address = "noreply@#{Rails.application.class.module_parent.name.downcase}.com"
|
74
|
-
@support_email = "support@#{Rails.application.class.module_parent.name.downcase}.com"
|
75
|
-
|
76
|
-
# Notification preferences
|
77
|
-
@enable_email_notifications = true
|
78
|
-
@enable_sms_notifications = false # Requires SMS provider configuration
|
79
|
-
|
80
|
-
# API versioning configuration
|
81
|
-
@api_version = 'v1' # Default API version
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|