rodauth-rails 0.3.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +42 -0
  3. data/README.md +169 -69
  4. data/lib/generators/rodauth/install_generator.rb +34 -17
  5. data/lib/generators/rodauth/migration/account_expiration.erb +7 -0
  6. data/lib/generators/rodauth/migration/active_sessions.erb +7 -0
  7. data/lib/generators/rodauth/migration/audit_logging.erb +16 -0
  8. data/lib/generators/rodauth/migration/base.erb +19 -0
  9. data/lib/generators/rodauth/migration/disallow_password_reuse.erb +5 -0
  10. data/lib/generators/rodauth/migration/email_auth.erb +7 -0
  11. data/lib/generators/rodauth/migration/jwt_refresh.erb +7 -0
  12. data/lib/generators/rodauth/migration/lockout.erb +11 -0
  13. data/lib/generators/rodauth/migration/otp.erb +7 -0
  14. data/lib/generators/rodauth/migration/password_expiration.erb +5 -0
  15. data/lib/generators/rodauth/migration/recovery_codes.erb +6 -0
  16. data/lib/generators/rodauth/migration/remember.erb +6 -0
  17. data/lib/generators/rodauth/migration/reset_password.erb +7 -0
  18. data/lib/generators/rodauth/migration/single_session.erb +5 -0
  19. data/lib/generators/rodauth/migration/sms_codes.erb +8 -0
  20. data/lib/generators/rodauth/migration/verify_account.erb +7 -0
  21. data/lib/generators/rodauth/migration/verify_login_change.erb +7 -0
  22. data/lib/generators/rodauth/migration/webauthn.erb +12 -0
  23. data/lib/generators/rodauth/migration_generator.rb +32 -0
  24. data/lib/generators/rodauth/migration_helpers.rb +69 -0
  25. data/lib/generators/rodauth/templates/{lib → app/lib}/rodauth_app.rb +26 -2
  26. data/lib/generators/rodauth/templates/config/initializers/sequel.rb +1 -5
  27. data/lib/generators/rodauth/templates/db/migrate/create_rodauth.rb +2 -167
  28. data/lib/rodauth/rails.rb +24 -5
  29. data/lib/rodauth/rails/app.rb +5 -4
  30. data/lib/rodauth/rails/feature.rb +69 -13
  31. data/lib/rodauth/rails/flash.rb +48 -0
  32. data/lib/rodauth/rails/railtie.rb +11 -0
  33. data/lib/rodauth/rails/tasks.rake +28 -0
  34. data/lib/rodauth/rails/version.rb +5 -0
  35. data/rodauth-rails.gemspec +6 -4
  36. metadata +31 -9
  37. data/lib/rodauth/rails/app/flash.rb +0 -50
@@ -0,0 +1,28 @@
1
+ namespace :rodauth do
2
+ task routes: :environment do
3
+ app = Rodauth::Rails.app
4
+
5
+ puts "Routes handled by #{app}:"
6
+
7
+ app.opts[:rodauths].each_key do |rodauth_name|
8
+ rodauth = Rodauth::Rails.rodauth(rodauth_name)
9
+
10
+ routes = rodauth.class.routes.map do |handle_method|
11
+ path_method = "#{handle_method.to_s.sub(/\Ahandle_/, "")}_path"
12
+
13
+ [
14
+ rodauth.public_send(path_method),
15
+ "rodauth#{rodauth_name && "(:#{rodauth_name})"}.#{path_method}",
16
+ ]
17
+ end
18
+
19
+ padding = routes.map { |path, _| path.length }.max
20
+
21
+ route_lines = routes.map do |path, code|
22
+ "#{path.ljust(padding)} #{code}"
23
+ end
24
+
25
+ puts "\n #{route_lines.join("\n ")}"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,5 @@
1
+ module Rodauth
2
+ module Rails
3
+ VERSION = "0.6.0"
4
+ end
5
+ end
@@ -1,6 +1,8 @@
1
+ require_relative "lib/rodauth/rails/version"
2
+
1
3
  Gem::Specification.new do |spec|
2
4
  spec.name = "rodauth-rails"
3
- spec.version = "0.3.1"
5
+ spec.version = Rodauth::Rails::VERSION
4
6
  spec.authors = ["Janko Marohnić"]
5
7
  spec.email = ["janko.marohnic@gmail.com"]
6
8
 
@@ -9,14 +11,14 @@ Gem::Specification.new do |spec|
9
11
  spec.homepage = "https://github.com/janko/rodauth-rails"
10
12
  spec.license = "MIT"
11
13
 
12
- spec.required_ruby_version = ">= 2.2.0"
14
+ spec.required_ruby_version = ">= 2.3"
13
15
 
14
16
  spec.files = Dir["README.md", "LICENSE.txt", "CHANGELOG.md", "lib/**/*", "*.gemspec"]
15
17
  spec.require_paths = ["lib"]
16
18
 
17
19
  spec.add_dependency "railties", ">= 4.2", "< 7"
18
- spec.add_dependency "rodauth", "~> 2.1"
19
- spec.add_dependency "sequel-activerecord_connection", "~> 1.0"
20
+ spec.add_dependency "rodauth", "~> 2.6"
21
+ spec.add_dependency "sequel-activerecord_connection", "~> 1.1"
20
22
  spec.add_dependency "tilt"
21
23
  spec.add_dependency "bcrypt"
22
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodauth-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-25 00:00:00.000000000 Z
11
+ date: 2020-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -36,28 +36,28 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '2.1'
39
+ version: '2.6'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '2.1'
46
+ version: '2.6'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sequel-activerecord_connection
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '1.0'
53
+ version: '1.1'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '1.0'
60
+ version: '1.1'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: tilt
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -98,7 +98,28 @@ files:
98
98
  - README.md
99
99
  - lib/generators/rodauth/install_generator.rb
100
100
  - lib/generators/rodauth/mailer_generator.rb
101
+ - lib/generators/rodauth/migration/account_expiration.erb
102
+ - lib/generators/rodauth/migration/active_sessions.erb
103
+ - lib/generators/rodauth/migration/audit_logging.erb
104
+ - lib/generators/rodauth/migration/base.erb
105
+ - lib/generators/rodauth/migration/disallow_password_reuse.erb
106
+ - lib/generators/rodauth/migration/email_auth.erb
107
+ - lib/generators/rodauth/migration/jwt_refresh.erb
108
+ - lib/generators/rodauth/migration/lockout.erb
109
+ - lib/generators/rodauth/migration/otp.erb
110
+ - lib/generators/rodauth/migration/password_expiration.erb
111
+ - lib/generators/rodauth/migration/recovery_codes.erb
112
+ - lib/generators/rodauth/migration/remember.erb
113
+ - lib/generators/rodauth/migration/reset_password.erb
114
+ - lib/generators/rodauth/migration/single_session.erb
115
+ - lib/generators/rodauth/migration/sms_codes.erb
116
+ - lib/generators/rodauth/migration/verify_account.erb
117
+ - lib/generators/rodauth/migration/verify_login_change.erb
118
+ - lib/generators/rodauth/migration/webauthn.erb
119
+ - lib/generators/rodauth/migration_generator.rb
120
+ - lib/generators/rodauth/migration_helpers.rb
101
121
  - lib/generators/rodauth/templates/app/controllers/rodauth_controller.rb
122
+ - lib/generators/rodauth/templates/app/lib/rodauth_app.rb
102
123
  - lib/generators/rodauth/templates/app/mailers/rodauth_mailer.rb
103
124
  - lib/generators/rodauth/templates/app/models/account.rb
104
125
  - lib/generators/rodauth/templates/app/views/rodauth/_email_auth_request_form.html.erb
@@ -164,17 +185,18 @@ files:
164
185
  - lib/generators/rodauth/templates/config/initializers/rodauth.rb
165
186
  - lib/generators/rodauth/templates/config/initializers/sequel.rb
166
187
  - lib/generators/rodauth/templates/db/migrate/create_rodauth.rb
167
- - lib/generators/rodauth/templates/lib/rodauth_app.rb
168
188
  - lib/generators/rodauth/views_generator.rb
169
189
  - lib/rodauth-rails.rb
170
190
  - lib/rodauth/features/rails.rb
171
191
  - lib/rodauth/rails.rb
172
192
  - lib/rodauth/rails/app.rb
173
- - lib/rodauth/rails/app/flash.rb
174
193
  - lib/rodauth/rails/controller_methods.rb
175
194
  - lib/rodauth/rails/feature.rb
195
+ - lib/rodauth/rails/flash.rb
176
196
  - lib/rodauth/rails/middleware.rb
177
197
  - lib/rodauth/rails/railtie.rb
198
+ - lib/rodauth/rails/tasks.rake
199
+ - lib/rodauth/rails/version.rb
178
200
  - rodauth-rails.gemspec
179
201
  homepage: https://github.com/janko/rodauth-rails
180
202
  licenses:
@@ -188,7 +210,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
188
210
  requirements:
189
211
  - - ">="
190
212
  - !ruby/object:Gem::Version
191
- version: 2.2.0
213
+ version: '2.3'
192
214
  required_rubygems_version: !ruby/object:Gem::Requirement
193
215
  requirements:
194
216
  - - ">="
@@ -1,50 +0,0 @@
1
- module Rodauth
2
- module Rails
3
- class App
4
- # Sets up Rails' flash integration.
5
- module Flash
6
- def self.load_dependencies(app)
7
- app.plugin :hooks
8
- end
9
-
10
- def self.configure(app)
11
- app.before { request.flash } # load flash
12
- app.after { request.commit_flash } # save flash
13
- end
14
-
15
- module InstanceMethods
16
- def flash
17
- request.flash
18
- end
19
- end
20
-
21
- module RequestMethods
22
- # If the redirect would bubble up outside of the Roda app, the after
23
- # hook would never get called, so we make sure to commit the flash.
24
- def redirect(*)
25
- commit_flash
26
- super
27
- end
28
-
29
- def flash
30
- rails_request.flash
31
- end
32
-
33
- def commit_flash
34
- if ActionPack.version >= Gem::Version.new("5.0.0")
35
- rails_request.commit_flash
36
- else
37
- # ActionPack 4.2 automatically commits flash
38
- end
39
- end
40
-
41
- private
42
-
43
- def rails_request
44
- ActionDispatch::Request.new(env)
45
- end
46
- end
47
- end
48
- end
49
- end
50
- end